-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
80 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import type { Request, Response } from 'express'; | ||
export interface DoSaveApplicationSettingResponse { | ||
success: boolean; | ||
} | ||
export default function handler(request: Request<unknown, unknown, { | ||
settingKey: string; | ||
settingValue: string; | ||
}>, response: Response): void; | ||
}>, response: Response<DoSaveApplicationSettingResponse>): void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
(() => { | ||
const urlPrefix = document.querySelector("main").dataset.urlPrefix; | ||
const getMessageElement = (formElement) => { | ||
return formElement.closest("tr").querySelectorAll(".formMessage")[0]; | ||
}; | ||
const submitFunction = (formEvent) => { | ||
const urlPrefix = document.querySelector('main').dataset | ||
.urlPrefix; | ||
function getMessageElement(formElement) { | ||
var _a; | ||
return (_a = formElement | ||
.closest('tr')) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.formMessage').item(0); | ||
} | ||
function submitFunction(formEvent) { | ||
formEvent.preventDefault(); | ||
const formElement = formEvent.currentTarget; | ||
const messageElement = getMessageElement(formElement); | ||
messageElement.innerHTML = "Saving... <i class=\"fas fa-circle-notch fa-spin\" aria-hidden=\"true\"></i>"; | ||
cityssm.postJSON(urlPrefix + "/admin/doSaveApplicationSetting", formElement, (responseJSON) => { | ||
messageElement.innerHTML = | ||
'Saving... <i class="fas fa-circle-notch fa-spin" aria-hidden="true"></i>'; | ||
cityssm.postJSON(`${urlPrefix}/admin/doSaveApplicationSetting`, formElement, (rawResponseJSON) => { | ||
const responseJSON = rawResponseJSON; | ||
messageElement.innerHTML = responseJSON.success | ||
? "<span class=\"has-text-success\">Updated Successfully</span>" | ||
: "<span class=\"has-text-danger\">Update Error</span>"; | ||
? '<span class="has-text-success">Updated Successfully</span>' | ||
: '<span class="has-text-danger">Update Error</span>'; | ||
}); | ||
}; | ||
const changeFunction = (inputEvent) => { | ||
} | ||
function changeFunction(inputEvent) { | ||
getMessageElement(inputEvent.currentTarget).innerHTML = | ||
"<span class=\"has-text-info\">Unsaved Changes</span>"; | ||
}; | ||
const formElements = document.querySelectorAll(".form--applicationSetting"); | ||
'<span class="has-text-info">Unsaved Changes</span>'; | ||
} | ||
const formElements = document.querySelectorAll('.form--applicationSetting'); | ||
for (const formElement of formElements) { | ||
formElement.addEventListener("submit", submitFunction); | ||
formElement.querySelectorAll(".input")[0].addEventListener("change", changeFunction); | ||
formElement.addEventListener('submit', submitFunction); | ||
formElement | ||
.querySelectorAll('.input') | ||
.item(0) | ||
.addEventListener('change', changeFunction); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,65 @@ | ||
/* eslint-disable unicorn/filename-case */ | ||
/* eslint-disable unicorn/filename-case, @eslint-community/eslint-comments/disable-enable-pair */ | ||
|
||
import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; | ||
declare const cityssm: cityssmGlobal; | ||
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' | ||
|
||
import type { DoSaveApplicationSettingResponse } from '../handlers/admin-post/doSaveApplicationSetting.js' | ||
|
||
(() => { | ||
declare const cityssm: cityssmGlobal | ||
;(() => { | ||
const urlPrefix = (document.querySelector('main') as HTMLElement).dataset | ||
.urlPrefix | ||
|
||
const urlPrefix = document.querySelector("main").dataset.urlPrefix; | ||
|
||
const getMessageElement = (formElement: HTMLFormElement | HTMLInputElement) => { | ||
return formElement.closest("tr").querySelectorAll(".formMessage")[0] as HTMLElement; | ||
}; | ||
function getMessageElement( | ||
formElement: HTMLFormElement | HTMLInputElement | ||
): HTMLElement { | ||
return formElement | ||
.closest('tr') | ||
?.querySelectorAll('.formMessage') | ||
.item(0) as HTMLElement | ||
} | ||
|
||
/* | ||
* Form | ||
*/ | ||
|
||
const submitFunction = (formEvent: Event) => { | ||
|
||
formEvent.preventDefault(); | ||
function submitFunction(formEvent: Event): void { | ||
formEvent.preventDefault() | ||
|
||
const formElement = formEvent.currentTarget as HTMLFormElement; | ||
const messageElement = getMessageElement(formElement); | ||
const formElement = formEvent.currentTarget as HTMLFormElement | ||
const messageElement = getMessageElement(formElement) | ||
|
||
messageElement.innerHTML = "Saving... <i class=\"fas fa-circle-notch fa-spin\" aria-hidden=\"true\"></i>"; | ||
messageElement.innerHTML = | ||
'Saving... <i class="fas fa-circle-notch fa-spin" aria-hidden="true"></i>' | ||
|
||
cityssm.postJSON(urlPrefix + "/admin/doSaveApplicationSetting", | ||
cityssm.postJSON( | ||
`${urlPrefix}/admin/doSaveApplicationSetting`, | ||
formElement, | ||
(responseJSON: { success: boolean }) => { | ||
(rawResponseJSON) => { | ||
const responseJSON = | ||
rawResponseJSON as unknown as DoSaveApplicationSettingResponse | ||
|
||
// eslint-disable-next-line no-unsanitized/property | ||
messageElement.innerHTML = responseJSON.success | ||
? "<span class=\"has-text-success\">Updated Successfully</span>" | ||
: "<span class=\"has-text-danger\">Update Error</span>"; | ||
? '<span class="has-text-success">Updated Successfully</span>' | ||
: '<span class="has-text-danger">Update Error</span>' | ||
} | ||
); | ||
}; | ||
) | ||
} | ||
|
||
const changeFunction = (inputEvent: Event) => { | ||
function changeFunction(inputEvent: Event): void { | ||
getMessageElement(inputEvent.currentTarget as HTMLInputElement).innerHTML = | ||
"<span class=\"has-text-info\">Unsaved Changes</span>"; | ||
}; | ||
|
||
'<span class="has-text-info">Unsaved Changes</span>' | ||
} | ||
|
||
const formElements = document.querySelectorAll(".form--applicationSetting") as NodeListOf<HTMLFormElement>; | ||
const formElements = document.querySelectorAll( | ||
'.form--applicationSetting' | ||
) as NodeListOf<HTMLFormElement> | ||
|
||
for (const formElement of formElements) { | ||
formElement.addEventListener("submit", submitFunction); | ||
formElement.querySelectorAll(".input")[0].addEventListener("change", changeFunction); | ||
formElement.addEventListener('submit', submitFunction) | ||
formElement | ||
.querySelectorAll('.input') | ||
.item(0) | ||
.addEventListener('change', changeFunction) | ||
} | ||
})(); | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.