Skip to content

Commit fccfc67

Browse files
feat: New isUnlockable prop and unlock dialog for the form controls
1 parent 9c24ad7 commit fccfc67

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

i18n/translations/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@
511511
"lock.unsaved.users": "Unsaved accounts",
512512
"lock.isLocked": "Unsaved changes by {email}",
513513
"lock.unlock": "Unlock",
514+
"lock.unlock.confirm": "You will take over the changes from <strong>{{ email }}</strong>. They will then be unable to edit the content.",
514515
"lock.unlock.submit": "Unlock and overwrite unsaved changes by <strong>{email}</strong>",
515516
"lock.isUnlocked": "Was unlocked by another user",
516517

panel/src/components/Forms/FormControls.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
{{ $t("form.preview") }}
4747
</k-dropdown-item>
4848
</template>
49+
<template v-if="isLocked && isUnlockable">
50+
<hr />
51+
<k-dropdown-item icon="lock" @click="unlock">
52+
{{ $t("lock.unlock") }}
53+
</k-dropdown-item>
54+
</template>
4955
</k-dropdown-content>
5056
</div>
5157
</template>
@@ -56,6 +62,7 @@ export const props = {
5662
editor: String,
5763
hasDiff: Boolean,
5864
isLocked: Boolean,
65+
isUnlockable: Boolean,
5966
modified: [String, Date],
6067
/**
6168
* Preview URL for changes
@@ -136,6 +143,28 @@ export default {
136143
}
137144
}
138145
});
146+
},
147+
unlock() {
148+
this.$panel.dialog.open({
149+
component: "k-text-dialog",
150+
props: {
151+
size: "small",
152+
submitButton: {
153+
icon: "lock",
154+
theme: "negative",
155+
text: this.$t("lock.unlock")
156+
},
157+
text: this.$t("lock.unlock.confirm", {
158+
email: this.editor
159+
})
160+
},
161+
on: {
162+
submit: () => {
163+
this.$panel.dialog.close();
164+
this.$emit("unlock");
165+
}
166+
}
167+
});
139168
}
140169
}
141170
};

0 commit comments

Comments
 (0)