Skip to content

Commit 396c285

Browse files
authored
feat: Implement publish option - EXO-72742,EXO-72744,EXO-73081 - Meeds-io/MIPs#161 (#1170)
Implement publish option
1 parent 1455f9a commit 396c285

File tree

10 files changed

+548
-21
lines changed

10 files changed

+548
-21
lines changed

notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_en.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ notes.publication.check.properties.label=Check the teaser
7272
notes.publication.publish.next.label=Next
7373
notes.publication.post.in.feed.label=Post in Activity stream of
7474
notes.publication.publish.save.label=Publish
75+
notes.publication.publish.in.list.label=Publish in a News list
76+
notes.publication.where.to.publish.label=Where to publish?
77+
notes.publication.who.will.see.label=Who will see?
78+
notes.publication.choose.location.label=Choose a location
79+
notes.publication.only.space.members.label=Only space members
80+
notes.publication.all.users.label=All users
81+
notes.publication.targets.others.label={0} Others
82+
notes.publication.targets.other.label={0} Other
83+
notes.publication.targets.label=News Targets
84+
notes.publication.targets.select.all.label=Select all
85+
notes.publication.all.users.audience.info=All users will see the article
86+
notes.publication.audience.restricted=Restricted: you cannot change it
87+
notes.publication.remove.selected.target.label=Remove selected target
88+
7589

7690
popup.confirm=Confirm
7791
popup.msg.confirmation=Confirmation

notes-webapp/src/main/resources/locale/portlet/notes/notesPortlet_fr.properties

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ notes.publication.check.properties.label=Vérifier l'accroche
7171
notes.publication.publish.next.label=Suivant
7272
notes.publication.post.in.feed.label=Publier dans le fil d'activités de
7373
notes.publication.publish.save.label=Publier
74+
notes.publication.publish.in.list.label=Publier dans une liste d'articles
75+
notes.publication.where.to.publish.label=O\u00FA publier ?
76+
notes.publication.who.will.see.label=Qui le verra ?
77+
notes.publication.choose.location.label=Sélectionner un emplacement
78+
notes.publication.only.space.members.label=Seuls les membres de l'espace
79+
notes.publication.all.users.label=Tous les utilisateurs
80+
notes.publication.targets.others.label={0} Autres
81+
notes.publication.targets.other.label={0} Autre
82+
notes.publication.targets.label=Cibles d'article
83+
notes.publication.targets.select.all.label=Sélectionner tout
84+
notes.publication.all.users.audience.info=Tous les utilisateurs verront l'article
85+
notes.publication.audience.restricted=Restreint : vous ne pouvez pas le modifier
86+
notes.publication.remove.selected.target.label=Supprimer la cible sélectionnée
7487

7588
popup.confirm=Confirmer
7689
popup.msg.confirmation=Confirmation

notes-webapp/src/main/webapp/skin/less/notes/notes.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@
217217
max-width: 335px;
218218
}
219219

220+
.custom-clear-button {
221+
top: 2px;
222+
right: 50px ~'; /** orientation=lt */ ';
223+
left: 50px ~'; /** orientation=rt */ ';
224+
}
220225
}
221226

222227
#editorMetadataDrawer, #editorPublicationDrawer {

notes-webapp/src/main/webapp/vue-app/notes-publication/components/NotePublicationDrawer.vue

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<v-overlay
2323
z-index="2000"
2424
:value="drawer"
25-
@click.native="drawer = false" />
25+
@click.native="closeDrawerByOverlay" />
2626
<exo-drawer
2727
id="editorPublicationDrawer"
2828
ref="publicationDrawer"
@@ -85,7 +85,8 @@
8585
</div>
8686
<div
8787
:class="{
88-
'col-6': expanded,
88+
'col-6': expanded && !editMode,
89+
'col-12': expanded && editMode,
8990
'mt-8': !expanded && stepper < 2 && !editMode,
9091
'mt-4': !expanded && stepper === 2 && !editMode,
9192
}"
@@ -117,20 +118,32 @@
117118
:ripple="false"
118119
color="primary"
119120
class="mt-n1 me-1" />
120-
<div class="d-flex flex-wrap">
121+
<div class="d-flex flex-wrap mb-6">
121122
<p class="me-2">
122123
{{ $t('notes.publication.post.in.feed.label') }}
123124
</p>
124125
<exo-space-avatar
125126
:space-id="spaceId"
126127
size="21"
127-
:extra-class="['mb-auto text-truncate', {
128+
:extra-class="['mb-2 text-truncate', {
128129
'post-feed-target': !expanded
129130
}]"
130131
bold-title
131132
popover />
132133
</div>
133134
</div>
135+
<note-publish-option
136+
ref="publishOption"
137+
:allowed-targets="allowedTargets"
138+
:is-publishing="isPublishing"
139+
:edit-mode="editMode"
140+
:expanded="expanded"
141+
:saved-settings="{
142+
published: publicationSettings?.publish,
143+
selectedAudience: publicationSettings?.selectedAudience,
144+
selectedTargets: savedTargets(publicationSettings?.selectedTargets)
145+
}"
146+
@updated="updatedPublicationSettings" />
134147
</div>
135148
</v-scroll-y-transition>
136149
</div>
@@ -149,7 +162,7 @@
149162
</v-btn>
150163
<v-btn
151164
class="btn btn-primary"
152-
:disabled="summaryLengthError"
165+
:disabled="summaryLengthError || !saveEnabled"
153166
:loading="isPublishing"
154167
@click="save">
155168
{{ saveButtonLabel }}
@@ -161,6 +174,7 @@
161174
</template>
162175

163176
<script>
177+
164178
export default {
165179
data() {
166180
return {
@@ -172,7 +186,8 @@ export default {
172186
summaryMaxLength: 1300,
173187
publicationSettings: {
174188
post: true
175-
}
189+
},
190+
currentPublicationSettings: {}
176191
};
177192
},
178193
props: {
@@ -184,23 +199,35 @@ export default {
184199
type: Boolean,
185200
default: false
186201
},
187-
spaceId: {
188-
type: String,
189-
default: null
190-
},
191202
editMode: {
192203
type: Boolean,
193204
default: false
205+
},
206+
params: {
207+
type: Object,
208+
default: null
194209
}
195210
},
196211
computed: {
212+
saveEnabled() {
213+
return !this.editMode || this.publicationSettingsUpdated;
214+
},
215+
publicationSettingsUpdated() {
216+
return JSON.stringify(this.currentPublicationSettings) !== JSON.stringify(this.publicationSettings);
217+
},
197218
saveButtonLabel() {
198-
return (!this.editMode && this.stepper === 1 && !this.expanded) && this.$t('notes.publication.publish.next.label')
219+
return (!this.editMode && !this.expanded && this.stepper === 1) && this.$t('notes.publication.publish.next.label')
199220
|| this.$t('notes.publication.publish.save.label');
200221
},
201222
summaryLengthError() {
202223
return this.noteObject?.properties?.summary?.length > this.summaryMaxLength;
203224
},
225+
spaceId() {
226+
return this.params?.spaceId;
227+
},
228+
allowedTargets() {
229+
return this.params?.allowedTargets;
230+
}
204231
},
205232
watch: {
206233
expanded() {
@@ -213,6 +240,14 @@ export default {
213240
}
214241
},
215242
methods: {
243+
updatedPublicationSettings(settings) {
244+
this.publicationSettings = structuredClone({
245+
post: this.publicationSettings.post
246+
});
247+
this.publicationSettings.publish = settings?.publish;
248+
this.publicationSettings.selectedTargets = settings?.selectedTargets;
249+
this.publicationSettings.selectedAudience = settings?.selectedAudience;
250+
},
216251
propertiesUpdated(properties) {
217252
if (!this.noteObject?.properties || !Object.keys(this.noteObject?.properties).length) {
218253
this.noteObject.properties = structuredClone(properties || {});
@@ -223,14 +258,26 @@ export default {
223258
this.updateCurrentNoteObjectProperties(properties);
224259
this.propertiesToSave = properties;
225260
},
261+
savedTargets(targets) {
262+
return targets?.map(target => {
263+
return this.allowedTargets[this.allowedTargets.findIndex(allowedTarget => allowedTarget.name === target)];
264+
});
265+
},
226266
open(noteObject) {
227267
this.noteObject = noteObject;
228268
if (this.editMode) {
229269
this.publicationSettings.post = this.noteObject?.activityPosted;
270+
this.publicationSettings.publish = this.noteObject?.published;
271+
this.publicationSettings.selectedTargets = this.noteObject?.targets;
272+
this.publicationSettings.selectedAudience = this.noteObject?.audience;
230273
}
274+
this.currentPublicationSettings = structuredClone(this.publicationSettings);
231275
this.cloneProperties();
232276
this.$refs.publicationDrawer.open();
233277
this.toggleExpand();
278+
setTimeout(() => {
279+
this.$refs.publishOption.initSettings();
280+
}, 200);
234281
this.$refs.propertiesForm?.initProperties();
235282
},
236283
toggleExpand() {
@@ -254,7 +301,13 @@ export default {
254301
this.stepper = 1;
255302
this.$refs.publicationDrawer.close();
256303
},
304+
cancelChanges() {
305+
this.$refs?.publishOption?.cancelChanges();
306+
},
257307
reset() {
308+
setTimeout(() => {
309+
this.cancelChanges();
310+
}, 1000);
258311
this.$emit('closed');
259312
},
260313
cancel() {
@@ -285,7 +338,14 @@ export default {
285338
this.noteObject.properties.featuredImage.mimeType = properties?.featuredImage?.mimeType;
286339
this.noteObject.properties.featuredImage.altText = properties?.featuredImage?.altText;
287340
this.noteObject.properties.featuredImage.toDelete = properties?.featuredImage?.toDelete;
288-
}
341+
},
342+
closeDrawerByOverlay() {
343+
if (this.editMode) {
344+
this.drawer = !this.drawer;
345+
return;
346+
}
347+
this.$root.$emit('close-featured-image-byOverlay');
348+
},
289349
}
290350
};
291351
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<!--
2+
This file is part of the Meeds project (https://meeds.io/).
3+
4+
Copyright (C) 2024 Meeds Association [email protected]
5+
6+
This program is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 3 of the License, or (at your option) any later version.
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public License
16+
along with this program; if not, write to the Free Software Foundation,
17+
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18+
-->
19+
20+
<template>
21+
<div>
22+
<v-overlay
23+
id="target-drawer-overlay"
24+
z-index="2100"
25+
:value="drawer"
26+
@click.native="drawer = false" />
27+
<exo-drawer
28+
id="publicationTargetsListDrawer"
29+
ref="publicationTargetsListDrawer"
30+
v-model="drawer"
31+
:right="!$vuetify.rtl">
32+
<template slot="title">
33+
<div class="d-flex my-auto text-header font-weight-bold text-color">
34+
{{ $t('notes.publication.targets.label') }}
35+
</div>
36+
</template>
37+
<template slot="content">
38+
<div class="pa-5">
39+
<note-publication-target-list
40+
:targets="targets"
41+
@unselect="unselectPublicationTarget" />
42+
</div>
43+
</template>
44+
</exo-drawer>
45+
</div>
46+
</template>
47+
48+
<script>
49+
export default {
50+
data() {
51+
return {
52+
drawer: false,
53+
targets: []
54+
};
55+
},
56+
created() {
57+
this.$root.$on('open-publication-target-list-drawer', this.open);
58+
this.$root.$on('close-publication-target-list-drawer', this.close);
59+
},
60+
methods: {
61+
unselectPublicationTarget(targetName) {
62+
this.$root.$emit('unselect-publication-target', targetName);
63+
},
64+
open(targets) {
65+
console.log('hello');
66+
this.targets = targets;
67+
this.$refs.publicationTargetsListDrawer.open();
68+
},
69+
close() {
70+
this.$refs.publicationTargetsListDrawer.close();
71+
}
72+
}
73+
};
74+
</script>

0 commit comments

Comments
 (0)