Skip to content

Commit

Permalink
feat: Implement Schedule option - EXO-72745 - Meeds-io/MIPs#161 (#1185)
Browse files Browse the repository at this point in the history
Implement Schedule option
  • Loading branch information
hakermi committed Nov 28, 2024
1 parent 706f4a1 commit c60f160
Show file tree
Hide file tree
Showing 8 changed files with 450 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ notes.publication.all.users.audience.info=All users will see the article
notes.publication.audience.restricted=Audience Restricted: you cannot change it
notes.publication.remove.selected.target.label=Remove selected target
notes.publication.list.targets.drawer.close.label=Close
notes.publication.schedule.label=Schedule
notes.publication.schedule.between.label=Between
notes.publication.schedule.from.label=From
notes.publication.schedule.until.label=Until



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ notes.publication.all.users.audience.info=Tous les utilisateurs verront l'articl
notes.publication.audience.restricted=Audience Restreint : vous ne pouvez pas le modifier
notes.publication.remove.selected.target.label=Supprimer la cible sélectionnée
notes.publication.list.targets.drawer.close.label=Fermer
notes.publication.schedule.label=Programmer
notes.publication.schedule.between.label=Entre
notes.publication.schedule.from.label=De
notes.publication.schedule.until.label=Jusqu'\u00E0

popup.confirm=Confirmer
popup.msg.confirmation=Confirmation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<div v-show="expanded || stepper === (2 - editMode)">
<div
:class="{'mt-8': !editMode}"
class="d-flex flex-column">
class="d-flex flex-column pb-10">
<v-scroll-y-transition hide-on-leave>
<div class="mb-2">
<div class="d-flex">
Expand All @@ -134,17 +134,31 @@
</div>
<note-publish-option
v-if="allowedTargets?.length"
ref="publishOption"
:allowed-targets="allowedTargets"
:is-publishing="isPublishing"
:edit-mode="editMode"
:expanded="expanded"
:saved-settings="{
:saved-publish-settings="{
published: publicationSettings?.publish,
selectedAudience: publicationSettings?.selectedAudience,
selectedTargets: savedTargets(publicationSettings?.selectedTargets)
}"
ref="publishOption"
class="mb-7"
@updated="updatedPublicationSettings" />
<note-schedule-option
v-if="scheduleAllowed"
:expanded="expanded"
:publish="publicationSettings?.publish"
:is-publishing="isPublishing"
:edit-mode="editMode"
:saved-schedule-settings="{
scheduled: currentScheduleSettings?.schedule,
postDate: currentScheduleSettings?.postDate,
unpublishDate: currentScheduleSettings?.unpublishDate
}"
ref="scheduleOption"
@updated="updatedScheduleSettings" />
</div>
</v-scroll-y-transition>
</div>
Expand Down Expand Up @@ -188,7 +202,9 @@ export default {
publicationSettings: {
post: true
},
currentPublicationSettings: {}
scheduleSettings: {},
currentPublicationSettings: {},
currentScheduleSettings: {}
};
},
props: {
Expand All @@ -210,6 +226,12 @@ export default {
}
},
computed: {
scheduleOptionEnabled() {
return eXo?.env?.portal?.newPublicationDrawerScheduleOptionEnabled;
},
scheduleAllowed() {
return this.scheduleOptionEnabled && (!this.editMode || (this.publicationSettings?.publish || !!this.noteObject?.schedulePostDate));
},
saveEnabled() {
return !this.editMode || this.publicationSettingsUpdated;
},
Expand All @@ -218,7 +240,8 @@ export default {
},
saveButtonLabel() {
return (!this.editMode && !this.expanded && this.stepper === 1) && this.$t('notes.publication.publish.next.label')
|| this.$t('notes.publication.publish.save.label');
|| !this.editMode && this.$t('notes.publication.publish.save.label')
|| this.$t('notes.button.publish');
},
summaryLengthError() {
return this.noteObject?.properties?.summary?.length > this.summaryMaxLength;
Expand All @@ -243,12 +266,17 @@ export default {
methods: {
updatedPublicationSettings(settings) {
this.publicationSettings = structuredClone({
post: this.publicationSettings.post
post: this.publicationSettings.post,
scheduleSettings: this.publicationSettings.scheduleSettings
});
this.publicationSettings.publish = settings?.publish;
this.publicationSettings.selectedTargets = settings?.selectedTargets;
this.publicationSettings.selectedAudience = settings?.selectedAudience;
},
updatedScheduleSettings(settings) {
this.scheduleSettings = structuredClone(settings);
this.publicationSettings.scheduleSettings = this.scheduleSettings;
},
propertiesUpdated(properties) {
if (!this.noteObject?.properties || !Object.keys(this.noteObject?.properties).length) {
this.noteObject.properties = structuredClone(properties || {});
Expand All @@ -268,16 +296,24 @@ export default {
this.noteObject = noteObject;
if (this.editMode) {
this.publicationSettings.post = this.noteObject?.activityPosted;
this.scheduleSettings.schedule = !!this.noteObject?.schedulePostDate || !!this.noteObject?.scheduleUnpublishDate;
this.scheduleSettings.postDate = this.noteObject?.schedulePostDate;
this.scheduleSettings.unpublishDate = this.noteObject?.scheduleUnpublishDate;
this.publicationSettings.scheduleSettings = this.scheduleSettings;
this.publicationSettings.publish = this.noteObject?.published;
this.publicationSettings.selectedTargets = this.noteObject?.targets;
this.publicationSettings.selectedAudience = this.noteObject?.audience;
}
this.currentScheduleSettings = structuredClone(this.scheduleSettings);
this.currentPublicationSettings = structuredClone(this.publicationSettings);
this.cloneProperties();
this.$refs.publicationDrawer.open();
this.toggleExpand();
setTimeout(() => {
this.$refs.publishOption.initSettings();
this.$refs?.publishOption?.initSettings();
this.$refs?.scheduleOption?.initSettings();
}, 200);
this.$refs.propertiesForm?.initProperties();
},
Expand All @@ -304,6 +340,7 @@ export default {
},
cancelChanges() {
this.$refs?.publishOption?.cancelChanges();
this.$refs?.scheduleOption?.cancelChanges();
},
reset() {
setTimeout(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default {
type: Array,
default: () => []
},
savedSettings: {
savedPublishSettings: {
type: Object,
default: null
},
Expand Down Expand Up @@ -233,9 +233,9 @@ export default {
},
methods: {
initSettings() {
this.publish = this.savedSettings?.published;
this.selectedTargets = this.savedSettings?.selectedTargets;
this.selectedAudience = this.savedAudience(this.savedSettings?.selectedAudience) || this.defaultAudience;
this.publish = this.savedPublishSettings?.published;
this.selectedTargets = this.savedPublishSettings?.selectedTargets;
this.selectedAudience = this.savedAudience(this.savedPublishSettings?.selectedAudience) || this.defaultAudience;
this.checkRestrictedAudience();
},
savedAudience(savedAudience) {
Expand Down
Loading

0 comments on commit c60f160

Please sign in to comment.