Skip to content

Commit

Permalink
feat: Implement edit note publication schedule - EXO-75389 - Meeds-io…
Browse files Browse the repository at this point in the history
…/MIPs#161 (#1214)

Implement edit note publication schedule
  • Loading branch information
hakermi authored and sofyenne committed Nov 19, 2024
1 parent c53cb8c commit 6cc7eb3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ notes.publication.advanced.option.label=Advanced options
notes.publication.hide.author.label=Hide author
notes.publication.hide.reaction.label=Hide reaction
notes.publication.success.message=Note successfully published
notes.publication.externalPage.publish.cancel.label=Cancel publishing

popup.confirm=Confirm
popup.msg.confirmation=Confirmation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ notes.publication.advanced.option.label=Options avancées
notes.publication.hide.author.label=Masquer l'auteur
notes.publication.hide.reaction.label=Masquer la réaction
notes.publication.success.message=Note publi\u00E9e avec succ\u00E8s
notes.publication.externalPage.publish.cancel.label=Annuler la publication

popup.confirm=Confirmer
popup.msg.confirmation=Confirmation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export async function getSavedNotePublicationSettings(id, lang) {
audience: article.audience,
schedulePostDate: article.schedulePostDate,
scheduleUnpublishDate: article.scheduleUnpublishDate,
fromExternalPage: article.fromExternalPage,
properties: article.properties ?? {}
};
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
:publish="publicationSettings?.publish"
:is-publishing="isPublishing"
:edit-mode="editMode"
:from-external-page="noteObject?.fromExternalPage"
:saved-schedule-settings="{
scheduled: currentScheduleSettings?.schedule,
postDate: currentScheduleSettings?.postDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@
:multiple="isMultipleSelectionOption"
class="d-flex ms-n1 mt-0 pt-0">
<v-radio
:label="cancelOption.label"
:value="cancelOption.value" />
v-if="fromExternalPage"
:label="$t('notes.publication.externalPage.publish.cancel.label')"
:value="CANCEL_SCHEDULE_OPTION" />
<v-radio
v-else-if="hasSavedUnpublishSchedule"
:label="$t('notes.publication.publish.cancel.label')"
:value="CANCEL_PUBLICATION_OPTION" />
<v-radio
v-else
:label="$t('notes.publication.schedule.cancel.label')"
:value="CANCEL_SCHEDULE_OPTION" />
<v-tooltip
v-if="canPublish"
:disabled="!isMultipleSelectionOption"
Expand Down Expand Up @@ -194,17 +203,19 @@
</template>
<script>
const SCHEDULE_OPTION = 'schedule';
const PUBLISH_NOW_OPTION = 'publish_now';
const CANCEL_SCHEDULE_OPTION = 'cancel_schedule';
const CANCEL_PUBLICATION_OPTION = 'cancel_unpublish';
export const SCHEDULE_OPTION = 'schedule';
export const PUBLISH_NOW_OPTION = 'publish_now';
export const CANCEL_SCHEDULE_OPTION = 'cancel_schedule';
export const CANCEL_PUBLICATION_OPTION = 'cancel_unpublish';
export default {
data() {
const { startDate, minStartDate, endDate } = this.initDateValues();
const betweenScheduleType = {label: this.$t('notes.publication.schedule.between.label'), value: 'between'};
const untilScheduleType = {label: this.$t('notes.publication.schedule.until.label'), value: 'until'};
const fromScheduleType = {label: this.$t('notes.publication.schedule.from.label'), value: 'from'};
return {
CANCEL_SCHEDULE_OPTION,
CANCEL_PUBLICATION_OPTION,
editScheduleOption: null,
schedule: false,
betweenScheduleType: betweenScheduleType,
Expand Down Expand Up @@ -257,6 +268,10 @@ export default {
canPublish: {
type: Boolean,
default: false
},
fromExternalPage: {
type: Boolean,
default: false
}
},
watch: {
Expand Down Expand Up @@ -298,10 +313,6 @@ export default {
isMultipleSelectionOption() {
return this.schedule && this.isUntilScheduleType && !this.hasSavedUnpublishSchedule;
},
cancelOption() {
return this.hasSavedUnpublishSchedule && {label: this.$t('notes.publication.publish.cancel.label'), value: CANCEL_PUBLICATION_OPTION}
|| {label: this.$t('notes.publication.schedule.cancel.label'), value: CANCEL_SCHEDULE_OPTION};
},
formattedStartDate() {
return this.startDate && this.formatDate(this.startDate) || '';
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ export default {
this.$notesService.updateNoteById(note).then(() => {
this.$notesService.saveNoteArticle(this.$noteUtils.noteToArticle(article, this.spaceId)).then(() => {
this.isPublishing = false;
this.getSavedNotePublicationSettings(this.note?.id);
this.$refs.publicationDrawer.close();
this.$root.$emit('show-alert', {type: 'success', message: this.$t('notes.publication.success.message')});
});
Expand All @@ -727,7 +728,8 @@ export default {
this.$notesService.updateNotePublication(editScheduleAction, scheduleSettings,
this.$noteUtils.noteToArticle(article, this.spaceId)).then(() => {
this.isPublishing = false;
this.$root.$emit('show-alert', {type: 'success', message: this.$t('notes.publication.success.message')});
this.$refs.publicationDrawer.close();
this.$root.$emit('show-alert', {type: 'success', message: this.$t('notes.publication.settings.update.success')});
});
}
},
Expand Down

0 comments on commit 6cc7eb3

Please sign in to comment.