22
22
<v-overlay
23
23
z-index =" 2000"
24
24
:value =" drawer"
25
- @click.native =" drawer = false " />
25
+ @click.native =" closeDrawerByOverlay " />
26
26
<exo-drawer
27
27
id =" editorPublicationDrawer"
28
28
ref =" publicationDrawer"
85
85
</div >
86
86
<div
87
87
:class =" {
88
- 'col-6': expanded,
88
+ 'col-6': expanded && !editMode,
89
+ 'col-12': expanded && editMode,
89
90
'mt-8': !expanded && stepper < 2 && !editMode,
90
91
'mt-4': !expanded && stepper === 2 && !editMode,
91
92
}"
117
118
:ripple =" false"
118
119
color =" primary"
119
120
class =" mt-n1 me-1" />
120
- <div class =" d-flex flex-wrap" >
121
+ <div class =" d-flex flex-wrap mb-6 " >
121
122
<p class =" me-2" >
122
123
{{ $t('notes.publication.post.in.feed.label') }}
123
124
</p >
124
125
<exo-space-avatar
125
126
:space-id =" spaceId"
126
127
size =" 21"
127
- :extra-class =" ['mb-auto text-truncate', {
128
+ :extra-class =" ['mb-2 text-truncate', {
128
129
'post-feed-target': !expanded
129
130
}]"
130
131
bold-title
131
132
popover />
132
133
</div >
133
134
</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" />
134
147
</div >
135
148
</v-scroll-y-transition >
136
149
</div >
149
162
</v-btn >
150
163
<v-btn
151
164
class =" btn btn-primary"
152
- :disabled =" summaryLengthError"
165
+ :disabled =" summaryLengthError || !saveEnabled "
153
166
:loading =" isPublishing"
154
167
@click =" save" >
155
168
{{ saveButtonLabel }}
161
174
</template >
162
175
163
176
<script >
177
+
164
178
export default {
165
179
data () {
166
180
return {
@@ -172,7 +186,8 @@ export default {
172
186
summaryMaxLength: 1300 ,
173
187
publicationSettings: {
174
188
post: true
175
- }
189
+ },
190
+ currentPublicationSettings: {}
176
191
};
177
192
},
178
193
props: {
@@ -184,23 +199,35 @@ export default {
184
199
type: Boolean ,
185
200
default: false
186
201
},
187
- spaceId: {
188
- type: String ,
189
- default: null
190
- },
191
202
editMode: {
192
203
type: Boolean ,
193
204
default: false
205
+ },
206
+ params: {
207
+ type: Object ,
208
+ default: null
194
209
}
195
210
},
196
211
computed: {
212
+ saveEnabled () {
213
+ return ! this .editMode || this .publicationSettingsUpdated ;
214
+ },
215
+ publicationSettingsUpdated () {
216
+ return JSON .stringify (this .currentPublicationSettings ) !== JSON .stringify (this .publicationSettings );
217
+ },
197
218
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' )
199
220
|| this .$t (' notes.publication.publish.save.label' );
200
221
},
201
222
summaryLengthError () {
202
223
return this .noteObject ? .properties ? .summary ? .length > this .summaryMaxLength ;
203
224
},
225
+ spaceId () {
226
+ return this .params ? .spaceId ;
227
+ },
228
+ allowedTargets () {
229
+ return this .params ? .allowedTargets ;
230
+ }
204
231
},
205
232
watch: {
206
233
expanded () {
@@ -213,6 +240,14 @@ export default {
213
240
}
214
241
},
215
242
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
+ },
216
251
propertiesUpdated (properties ) {
217
252
if (! this .noteObject ? .properties || ! Object .keys (this .noteObject ? .properties ).length ) {
218
253
this .noteObject .properties = structuredClone (properties || {});
@@ -223,14 +258,26 @@ export default {
223
258
this .updateCurrentNoteObjectProperties (properties);
224
259
this .propertiesToSave = properties;
225
260
},
261
+ savedTargets (targets ) {
262
+ return targets? .map (target => {
263
+ return this .allowedTargets [this .allowedTargets .findIndex (allowedTarget => allowedTarget .name === target)];
264
+ });
265
+ },
226
266
open (noteObject ) {
227
267
this .noteObject = noteObject;
228
268
if (this .editMode ) {
229
269
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 ;
230
273
}
274
+ this .currentPublicationSettings = structuredClone (this .publicationSettings );
231
275
this .cloneProperties ();
232
276
this .$refs .publicationDrawer .open ();
233
277
this .toggleExpand ();
278
+ setTimeout (() => {
279
+ this .$refs .publishOption .initSettings ();
280
+ }, 200 );
234
281
this .$refs .propertiesForm ? .initProperties ();
235
282
},
236
283
toggleExpand () {
@@ -254,7 +301,13 @@ export default {
254
301
this .stepper = 1 ;
255
302
this .$refs .publicationDrawer .close ();
256
303
},
304
+ cancelChanges () {
305
+ this .$refs ? .publishOption ? .cancelChanges ();
306
+ },
257
307
reset () {
308
+ setTimeout (() => {
309
+ this .cancelChanges ();
310
+ }, 1000 );
258
311
this .$emit (' closed' );
259
312
},
260
313
cancel () {
@@ -285,7 +338,14 @@ export default {
285
338
this .noteObject .properties .featuredImage .mimeType = properties? .featuredImage ? .mimeType ;
286
339
this .noteObject .properties .featuredImage .altText = properties? .featuredImage ? .altText ;
287
340
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
+ },
289
349
}
290
350
};
291
351
< / script>
0 commit comments