Improve role colours and ordering
This commit is contained in:
parent
1078fa3f78
commit
070ec8abd4
|
@ -109,7 +109,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
{#if fieldColour}
|
{#if fieldColour}
|
||||||
<span class="option-colour">
|
<span class="option-colour">
|
||||||
<StatusLight custom color={fieldColour} />
|
<StatusLight size="L" color={fieldColour} />
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
<svg
|
<svg
|
||||||
|
@ -182,7 +182,7 @@
|
||||||
</svg>
|
</svg>
|
||||||
{#if getOptionColour(option, idx)}
|
{#if getOptionColour(option, idx)}
|
||||||
<span class="option-colour">
|
<span class="option-colour">
|
||||||
<StatusLight custom color={getOptionColour(option, idx)} />
|
<StatusLight size="L" color={getOptionColour(option, idx)} />
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { Select } from "@budibase/bbui"
|
import { Select } from "@budibase/bbui"
|
||||||
import { roles } from "stores/backend"
|
import { roles } from "stores/backend"
|
||||||
|
import { RoleUtils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
export let error
|
export let error
|
||||||
|
@ -12,5 +13,6 @@
|
||||||
options={$roles}
|
options={$roles}
|
||||||
getOptionLabel={role => role.name}
|
getOptionLabel={role => role.name}
|
||||||
getOptionValue={role => role._id}
|
getOptionValue={role => role._id}
|
||||||
|
getOptionColour={role => RoleUtils.getRoleColour(role._id)}
|
||||||
{error}
|
{error}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
import { RoleUtils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export function createRolesStore() {
|
export function createRolesStore() {
|
||||||
const { subscribe, update, set } = writable([])
|
const { subscribe, update, set } = writable([])
|
||||||
|
@ -7,7 +8,13 @@ export function createRolesStore() {
|
||||||
const actions = {
|
const actions = {
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
const roles = await API.getRoles()
|
const roles = await API.getRoles()
|
||||||
set(roles)
|
set(
|
||||||
|
roles.sort((a, b) => {
|
||||||
|
const priorityA = RoleUtils.getRolePriority(a._id)
|
||||||
|
const priorityB = RoleUtils.getRolePriority(b._id)
|
||||||
|
return priorityA > priorityB ? -1 : 1
|
||||||
|
})
|
||||||
|
)
|
||||||
},
|
},
|
||||||
delete: async role => {
|
delete: async role => {
|
||||||
await API.deleteRole({
|
await API.deleteRole({
|
||||||
|
|
|
@ -18,5 +18,5 @@ export const getRolePriority = roleId => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getRoleColour = roleId => {
|
export const getRoleColour = roleId => {
|
||||||
return RoleColours[roleId] ?? "#ffa500"
|
return RoleColours[roleId] ?? "rgb(20, 115, 230)"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue