Skip to content

Commit

Permalink
Assignment3
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadwal Sinha committed Nov 23, 2023
1 parent 936f07c commit 3656afa
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions ui/actions/nuxeo-favorites-toggle-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,33 @@ import '../nuxeo-button-styles.js';
*/
_toggle() {
if (!this.favorite) {
this.$.opAdd.execute().then(() => {
this.dispatchEvent(
new CustomEvent('added-to-favorites', {
composed: true,
bubbles: true,
detail: { doc: this.document },
}),
);
this._setFavorite(true);
});
const addToFavorite = window.confirm("Do you want to add it to favorites?");
if (addToFavorite) {
this.$.opAdd.execute().then(() => {
this.dispatchEvent(
new CustomEvent('added-to-favorites', {
composed: true,
bubbles: true,
detail: { doc: this.document },
}),
);
this._setFavorite(true);
});
}
} else {
this.$.opRemove.execute().then(() => {
this.dispatchEvent(
new CustomEvent('removed-from-favorites', {
composed: true,
bubbles: true,
detail: { doc: this.document },
}),
);
this._setFavorite(false);
});
const removeFromFavorite = window.confirm("Do you want to remove it from favorites?");
if (removeFromFavorite) {
this.$.opRemove.execute().then(() => {
this.dispatchEvent(
new CustomEvent('removed-from-favorites', {
composed: true,
bubbles: true,
detail: { doc: this.document },
}),
);
this._setFavorite(false);
});
}
}
}

Expand Down

0 comments on commit 3656afa

Please sign in to comment.