deepsource-autofix-76c6eb20
Dan Gowans 2024-06-27 09:14:55 -04:00
parent 2399765145
commit 8fa4fcb054
5 changed files with 59 additions and 22 deletions

View File

@ -264,11 +264,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
function moveOccupancyTypeField(clickEvent) { function moveOccupancyTypeField(clickEvent) {
const buttonElement = clickEvent.currentTarget; const buttonElement = clickEvent.currentTarget;
const occupancyTypeFieldId = clickEvent.currentTarget.closest('.container--occupancyTypeField').dataset.occupancyTypeFieldId; const occupancyTypeFieldId = clickEvent.currentTarget.closest('.container--occupancyTypeField').dataset.occupancyTypeFieldId;
cityssm.postJSON(los.urlPrefix + cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
'/admin/' + ? 'doMoveOccupancyTypeFieldUp'
(buttonElement.dataset.direction === 'up' : // eslint-disable-next-line no-secrets/no-secrets
? 'doMoveOccupancyTypeFieldUp' 'doMoveOccupancyTypeFieldDown'}`, {
: 'doMoveOccupancyTypeFieldDown'), {
occupancyTypeFieldId, occupancyTypeFieldId,
moveToEnd: clickEvent.shiftKey ? '1' : '0' moveToEnd: clickEvent.shiftKey ? '1' : '0'
}, occupancyTypeResponseHandler); }, occupancyTypeResponseHandler);

View File

@ -388,7 +388,7 @@ type ResponseJSON =
modalElement.querySelector( modalElement.querySelector(
'#occupancyTypeFieldEdit--isRequired' '#occupancyTypeFieldEdit--isRequired'
) as HTMLSelectElement ) as HTMLSelectElement
).value = (occupancyTypeField.isRequired ?? false) ? '1' : '0' ).value = occupancyTypeField.isRequired ?? false ? '1' : '0'
minimumLengthElement = modalElement.querySelector( minimumLengthElement = modalElement.querySelector(
'#occupancyTypeFieldEdit--minimumLength' '#occupancyTypeFieldEdit--minimumLength'
@ -481,11 +481,12 @@ type ResponseJSON =
).dataset.occupancyTypeFieldId ).dataset.occupancyTypeFieldId
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + `${los.urlPrefix}/admin/${
'/admin/' + buttonElement.dataset.direction === 'up'
(buttonElement.dataset.direction === 'up'
? 'doMoveOccupancyTypeFieldUp' ? 'doMoveOccupancyTypeFieldUp'
: 'doMoveOccupancyTypeFieldDown'), : // eslint-disable-next-line no-secrets/no-secrets
'doMoveOccupancyTypeFieldDown'
}`,
{ {
occupancyTypeFieldId, occupancyTypeFieldId,
moveToEnd: clickEvent.shiftKey ? '1' : '0' moveToEnd: clickEvent.shiftKey ? '1' : '0'

View File

@ -211,18 +211,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
/* /*
* Colours * Colours
*/ */
const hues = ['red', 'green', 'orange', 'blue', 'pink', 'yellow', 'purple']; const hues = [
'red',
'green',
'orange',
'blue',
'pink',
'yellow',
'purple'
];
const luminosity = ['bright', 'light', 'dark']; const luminosity = ['bright', 'light', 'dark'];
function getRandomColor(seedString) { function getRandomColor(seedString) {
let actualSeedString = seedString; let actualSeedString = seedString;
if (actualSeedString.length < 2) { if (actualSeedString.length < 2) {
actualSeedString = actualSeedString + 'a1'; actualSeedString += 'a1';
} }
return exports.randomColor({ return exports.randomColor({
seed: actualSeedString + actualSeedString, seed: actualSeedString + actualSeedString,
hue: hues[actualSeedString.codePointAt(actualSeedString.length - 1) % hues.length], hue: hues[actualSeedString.codePointAt(actualSeedString.length - 1) %
luminosity: luminosity[actualSeedString.codePointAt(actualSeedString.length - 2) % hues.length],
luminosity.length] luminosity: luminosity[actualSeedString.codePointAt(actualSeedString.length - 2) % luminosity.length]
}); });
} }
/* /*

View File

@ -7,10 +7,29 @@ import type { Options as BulmaCalendarOptions } from 'bulma-calendar'
import type * as globalTypes from '../types/globalTypes.js' import type * as globalTypes from '../types/globalTypes.js'
type RandomColorHue =
| 'red'
| 'orange'
| 'yellow'
| 'green'
| 'blue'
| 'purple'
| 'pink'
| 'monochrome'
type RandomColorLuminosity = 'bright' | 'light' | 'dark'
declare const cityssm: cityssmGlobal declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS declare const bulmaJS: BulmaJS
declare const exports: Record<string, unknown> & { declare const exports: Record<string, unknown> & {
aliases: Record<string, string> aliases: Record<string, string>
randomColor: (options?: {
hue?: RandomColorHue
luminosity?: RandomColorLuminosity
count?: number
seed?: number | string
format?: 'rgb' | 'rgba' | 'rgbArray' | 'hsl' | 'hsla' | 'hslArray' | 'hex'
alpha?: number
}) => string
} }
;(() => { ;(() => {
/* /*
@ -301,25 +320,35 @@ declare const exports: Record<string, unknown> & {
* Colours * Colours
*/ */
const hues = ['red', 'green', 'orange', 'blue', 'pink', 'yellow', 'purple'] const hues = [
const luminosity = ['bright', 'light', 'dark'] 'red',
'green',
'orange',
'blue',
'pink',
'yellow',
'purple'
] as RandomColorHue[]
const luminosity = ['bright', 'light', 'dark'] as RandomColorLuminosity[]
function getRandomColor(seedString: string): string { function getRandomColor(seedString: string): string {
let actualSeedString = seedString let actualSeedString = seedString
if (actualSeedString.length < 2) { if (actualSeedString.length < 2) {
actualSeedString = actualSeedString + 'a1' actualSeedString += 'a1'
} }
return exports.randomColor({ return exports.randomColor({
seed: actualSeedString + actualSeedString, seed: actualSeedString + actualSeedString,
hue: hues[ hue: hues[
actualSeedString.codePointAt(actualSeedString.length - 1)! % hues.length (actualSeedString.codePointAt(actualSeedString.length - 1) as number) %
hues.length
], ],
luminosity: luminosity:
luminosity[ luminosity[
actualSeedString.codePointAt(actualSeedString.length - 2)! % (actualSeedString.codePointAt(
luminosity.length actualSeedString.length - 2
) as number) % luminosity.length
] ]
}) })
} }

File diff suppressed because one or more lines are too long