Gestion d'update de timestamp
This commit is contained in:
parent
c3076fdbfc
commit
3782ed9055
@ -212,6 +212,11 @@ export class RdDItemSheet extends ItemSheet {
|
||||
this.html.find('.item-vendre').click(async event => RdDSheetUtility.getItem(event, this.actor)?.proposerVente());
|
||||
this.html.find('.item-montrer').click(async event => RdDSheetUtility.getItem(event, this.actor)?.postItemToChat());
|
||||
this.html.find('.item-action').click(async event => RdDSheetUtility.getItem(event, this.actor)?.actionPrincipale(this.actor, async () => this.render(true)));
|
||||
|
||||
const updateItemTimestamp = (path, timestamp) => this.item.update({ [path]: duplicate(timestamp) })
|
||||
|
||||
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.debut', updateItemTimestamp);
|
||||
RdDTimestamp.handleTimestampEditor(this.html, 'system.temporel.fin', updateItemTimestamp);
|
||||
}
|
||||
|
||||
_getEventActor(event) {
|
||||
@ -220,6 +225,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
return actor;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async _onSelectCategorie(event) {
|
||||
event.preventDefault();
|
||||
|
@ -86,6 +86,7 @@ export class RdDTimestamp {
|
||||
static formulesDuree() {
|
||||
return FORMULES_DUREE
|
||||
}
|
||||
|
||||
static formulesPeriode() {
|
||||
return FORMULES_PERIODE
|
||||
}
|
||||
@ -98,6 +99,32 @@ export class RdDTimestamp {
|
||||
return `<img class="img-signe-heure" src="${signe.webp}" alt="${signe.label}"/>`
|
||||
}
|
||||
|
||||
static handleTimestampEditor(html, path, consumeTimestamp = async (path, timestamp) => {}) {
|
||||
const fields = {
|
||||
annee: html.find(`input[name="${path}.annee"]`),
|
||||
mois: html.find(`select[name="${path}.mois"]`),
|
||||
jourDuMois: html.find(`input[name="${path}.jourDuMois"]`),
|
||||
heure: html.find(`select[name="${path}.heure"]`),
|
||||
minute: html.find(`input[name="${path}.minute"]`)
|
||||
};
|
||||
|
||||
async function onChangeTimestamp(fields, path) {
|
||||
const annee = Number(fields.annee.val());
|
||||
const mois = fields.mois.val();
|
||||
const jour = Number(fields.jourDuMois.val());
|
||||
const heure = fields.heure.val();
|
||||
const minute = Number(fields.minute.val());
|
||||
await consumeTimestamp(path, RdDTimestamp.timestamp(annee, mois, jour, heure, minute));
|
||||
}
|
||||
|
||||
fields.annee.change(async (event) => await onChangeTimestamp(fields, path));
|
||||
fields.mois.change(async (event) => await onChangeTimestamp(fields, path));
|
||||
fields.jourDuMois.change(async (event) => await onChangeTimestamp(fields, path));
|
||||
fields.heure.change(async (event) => await onChangeTimestamp(fields, path));
|
||||
fields.minute.change(async (event) => await onChangeTimestamp(fields, path));
|
||||
}
|
||||
|
||||
|
||||
static findHeure(heure) {
|
||||
heure = Grammar.toLowerCaseNoAccentNoSpace(heure);
|
||||
let parHeureOuLabel = DEFINITION_HEURES.filter(it => (it.heure) == parseInt(heure) % RDD_HEURES_PAR_JOUR || Grammar.toLowerCaseNoAccentNoSpace(it.label) == heure);
|
||||
|
Loading…
Reference in New Issue
Block a user