Tiny fix in saving mixin

This commit is contained in:
Lea Verou
2025-04-02 13:44:44 -04:00
parent 6162b8b115
commit 6b3edb8a56
2 changed files with 9 additions and 8 deletions

View File

@@ -17,8 +17,8 @@ export default {
this.saved = this.controller.saved.find(p => p.uid === this.uid);
}
this.controller.addEventListener('delete', ({ detail: palette }) => {
if (palette.uid === this.saved?.uid) {
this.controller.addEventListener('delete', ({ detail: entity }) => {
if (entity.uid === this.saved?.uid) {
this.postDelete();
}
});
@@ -61,7 +61,8 @@ export default {
async save({ title } = {}) {
let uid = this.uid;
this.saved ??= { id: this.paletteId, uid: this.uid };
this.saved ??= { uid: this.uid };
this.saved.id = this.id;
if (title) {
// Renaming
@@ -75,7 +76,7 @@ export default {
this.saved = this.controller.save(this.saved);
if (uid !== this.saved.uid) {
// UID changed (most likely from saving a new palette)
// UID changed (most likely from saving a new entity)
this.uid = this.saved.uid;
this.permalink.set('uid', this.uid);
this.permalink.updateLocation();

View File

@@ -44,11 +44,11 @@ let paletteAppSpec = {
data() {
let appRoot = document.querySelector('#palette-app');
let paletteId = appRoot.dataset.paletteId;
let palette = allPalettes[paletteId];
let id = appRoot.dataset.paletteId;
let palette = allPalettes[id];
return {
paletteId,
id,
originalTitle: palette.title,
originalColors: palette.colors,
hueRanges,
@@ -121,7 +121,7 @@ let paletteAppSpec = {
code() {
let ret = {};
for (let language of ['html', 'css']) {
let code = getPaletteCode(this.paletteId, this.colors, this.tweaked, { language, cdnUrl });
let code = getPaletteCode(this.id, this.colors, this.tweaked, { language, cdnUrl });
ret[language] = {
raw: code,
highlighted: Prism.highlight(code, Prism.languages[language], language),