Skip to content

Commit 6172226

Browse files
committed
Lock Slug field by default
1 parent 3b3875a commit 6172226

File tree

4 files changed

+46
-3
lines changed

4 files changed

+46
-3
lines changed

packages/sprinkle-admin/app/locale/en_US/messages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
'NOT_FOUND' => 'Group not found',
6161
'PAGE' => 'Groups',
6262
'PAGE_DESCRIPTION' => 'A listing of the groups for your site. Provides management tools for editing and deleting groups.',
63+
'SLUG_UNMODIFIABLE' => 'The slug should not be changed. Click to unlock and use with caution.',
6364
'UPDATE' => 'Details updated for group <strong>{{name}}</strong>',
6465
'USERS' => 'Users in this group',
6566
],
@@ -110,6 +111,7 @@
110111
'PAGE_DESCRIPTION' => 'A listing of the roles for your site. Provides management tools for editing and deleting roles.',
111112
'PERMISSIONS' => 'Role permissions',
112113
'PERMISSIONS_UPDATED' => 'Permissions updated for role <strong>{{name}}</strong>',
114+
'SLUG_UNMODIFIABLE' => 'The slug should not be changed. Click to unlock and use with caution.',
113115
'UPDATE' => 'Update Roles',
114116
'UPDATED' => 'Details updated for role <strong>{{name}}</strong>',
115117
'USERS' => 'Users with this role',

packages/sprinkle-admin/app/locale/fr_FR/messages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
'NOT_FOUND' => 'Groupe non trouvé',
6161
'PAGE' => 'Groupes',
6262
'PAGE_DESCRIPTION' => 'Une liste des groupes pour votre site. Fournit des outils de gestion pour éditer et supprimer des groupes.',
63+
'SLUG_UNMODIFIABLE' => 'Le slug ne devrait pas être modifié. Cliquez pour déverrouiller et utilisez avec précaution.',
6364
'UPDATE' => 'Les détails du groupe <strong>{{name}}</strong> ont été enregistrés',
6465
'USERS' => 'Utilisateurs dans ce groupe',
6566
],
@@ -110,6 +111,7 @@
110111
'PAGE_DESCRIPTION' => 'Une liste des rôles de votre site. Fournit des outils de gestion pour modifier et supprimer des rôles.',
111112
'PERMISSIONS' => 'Autorisations associés à ce rôle',
112113
'PERMISSIONS_UPDATED' => 'Autorisations mises à jour pour le rôle <strong>{{name}}</strong>',
114+
'SLUG_UNMODIFIABLE' => 'Le slug ne devrait pas être modifié. Cliquez pour déverrouiller et utilisez avec précaution.',
113115
'UPDATE' => 'Mettre à jour les rôles',
114116
'UPDATED' => 'Détails mis à jour pour le rôle <strong>{{name}}</strong>',
115117
'USERS' => 'Utilisateurs avec ce rôle',

packages/theme-pink-cupcake/src/components/Pages/Admin/Group/GroupForm.vue

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { watch } from 'vue'
2+
import { computed, ref, watch } from 'vue'
33
import { useGroupApi } from '@userfrosting/sprinkle-admin/composables'
44
import type { GroupInterface } from '@userfrosting/sprinkle-account/interfaces'
55
@@ -13,6 +13,15 @@ const props = defineProps<{ group?: GroupInterface }>()
1313
*/
1414
const { createGroup, updateGroup, r$, formData, apiLoading, resetForm } = useGroupApi()
1515
16+
/**
17+
* Helper methods & Variables
18+
*/
19+
const slugForcedUnlocked = ref<boolean>(false)
20+
const disabledChange = computed<boolean>(() => {
21+
if (slugForcedUnlocked.value) return false
22+
return props.group != null
23+
})
24+
1625
/**
1726
* Watchers - Watch for changes in the group prop and update formData
1827
* accordingly. Useful when the group prop is updated from the parent component,
@@ -81,9 +90,20 @@ const submitForm = async () => {
8190
<label class="uk-form-label" for="form-stacked-text">{{ $t('SLUG') }}</label>
8291
<div class="uk-inline uk-width-1-1">
8392
<font-awesome-icon class="fa-form-icon" icon="tag" fixed-width />
93+
<button
94+
class="uk-button uk-button-default uk-form-button"
95+
type="button"
96+
:uk-tooltip="$t('GROUP.SLUG_UNMODIFIABLE')"
97+
@click="slugForcedUnlocked = !slugForcedUnlocked"
98+
v-if="props.group != null">
99+
<font-awesome-icon
100+
fixed-width
101+
:icon="slugForcedUnlocked ? 'lock-open' : 'lock'" />
102+
</button>
84103
<input
85104
class="uk-input"
86105
:class="{ 'uk-form-danger': r$.slug.$error }"
106+
:disabled="disabledChange"
87107
type="text"
88108
:placeholder="$t('SLUG')"
89109
aria-label="Group Slug"

packages/theme-pink-cupcake/src/components/Pages/Admin/Role/RoleForm.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { watch } from 'vue'
2+
import { computed, ref, watch } from 'vue'
33
import type { RoleInterface } from '@userfrosting/sprinkle-account/interfaces'
44
import { useRoleApi } from '@userfrosting/sprinkle-admin/composables'
55
@@ -13,6 +13,15 @@ const props = defineProps<{ role?: RoleInterface }>()
1313
*/
1414
const { createRole, updateRole, r$, formData, apiLoading, resetForm } = useRoleApi()
1515
16+
/**
17+
* Helper methods & Variables
18+
*/
19+
const slugForcedUnlocked = ref<boolean>(false)
20+
const disabledChange = computed<boolean>(() => {
21+
if (slugForcedUnlocked.value) return false
22+
return props.role != null
23+
})
24+
1625
/**
1726
* Watchers - Watch for changes in the role prop and update formData
1827
* accordingly. Useful when the role prop is updated from the parent component,
@@ -80,9 +89,20 @@ const submitForm = async () => {
8089
<label class="uk-form-label" for="form-stacked-text">{{ $t('SLUG') }}</label>
8190
<div class="uk-inline uk-width-1-1">
8291
<font-awesome-icon class="fa-form-icon" icon="tag" fixed-width />
92+
<button
93+
class="uk-button uk-button-default uk-form-button"
94+
type="button"
95+
:uk-tooltip="$t('ROLE.SLUG_UNMODIFIABLE')"
96+
@click="slugForcedUnlocked = !slugForcedUnlocked"
97+
v-if="props.role != null">
98+
<font-awesome-icon
99+
fixed-width
100+
:icon="slugForcedUnlocked ? 'lock-open' : 'lock'" />
101+
</button>
83102
<input
84103
class="uk-input"
85104
:class="{ 'uk-form-danger': r$.slug.$error }"
105+
:disabled="disabledChange"
86106
type="text"
87107
:placeholder="$t('SLUG')"
88108
aria-label="Role Slug"
@@ -91,7 +111,6 @@ const submitForm = async () => {
91111
v-model="formData.slug" />
92112
<UFFormValidationError :errors="r$.$errors.slug" />
93113
</div>
94-
<!-- TODO : Disable + unlock button; Auto generate slug -->
95114
</div>
96115

97116
<div class="uk-margin">

0 commit comments

Comments
 (0)