Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Widget UID & page ID on creation #1700

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<template>
<f7-col>
<f7-list inline-labels accordion-list no-hairline-md>
<f7-list-input label="ID" type="text" placeholder="ID" :value="page.uid" @input="page.uid = $event.target.value"
required validate pattern="[A-Za-z0-9_]+" error-message="Required. Alphanumeric &amp; underscores only" :disabled="!createMode" />
<f7-list-input label="Label" type="text" placeholder="Label" :value="page.config.label" @input="page.config.label = $event.target.value" clear-button />
<f7-list-input label="ID" type="text" placeholder="Required" :value="page.uid" @input="page.uid = $event.target.value"
:clear-button="createMode" :info="(createMode) ? 'Note: cannot be changed after the creation' : ''"
required validate pattern="[A-Za-z0-9_]+" error-message="Required. A-Z,a-z,0-9,_ only" :disabled="!createMode" />
<f7-list-input label="Label" type="text" placeholder="Label" :value="page.config.label" @input="page.config.label = $event.target.value" required validate clear-button />
<f7-list-item accordion-item title="Sidebar &amp; Visibility" :disabled="page.uid === 'overview'">
<f7-accordion-content>
<f7-list-item ref="pageVisibility" title="Visible only to" smart-select :smart-select-params="{openIn: 'popover'}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ export default {
},
save (stay) {
if (!this.widget.uid) {
this.$f7.dialog.alert('Please give an ID to the widget')
this.$f7.dialog.alert('Please give an UID to the widget')
return
} else if (!/^[A-Za-z0-9_]+$/.test(this.widget.uid)) {
this.$f7.dialog.alert('Widget UID is only allowed to contain A-Z,a-z,0-9,_')
return
}
// if (!this.widget.config.label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export default {
if (!this.page.uid) {
this.$f7.dialog.alert('Please give an ID to the page')
return
} else if (!/^[A-Za-z0-9_]+$/.test(this.page.uid)) {
this.$f7.dialog.alert('Page ID is only allowed to contain A-Z,a-z,0-9,_')
return
}
if (!this.page.config.label) {
this.$f7.dialog.alert('Please give a label to the page')
Expand Down