Files
lucia-frontend/src/stores/conformanceInput.js
Cindy Chang d6cb329a5c fix #258. Compare page and Performance pages are featured with formatted x ticks.
The author supposes this issue is not a bug but a feature.
2024-06-07 15:55:51 +08:00

70 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineStore } from "pinia";
import moment from 'moment';
export default defineStore('conformanceInputStore', {
state: () => ({
inputDataToSave: {
inputStart: null, // 有待釐清start 是活動的開始,還是時間的開始?
inputEnd: null,
min: null,
max: null,
type: null,
task: null,
},
activityRadioData: {
category: null,
task: ['', ''],
},
}),
getters: {
},
actions: {
/** UNUSED
* Set input activity radio data
* @param {object} actRadioData
*/
setActivityRadioStartEndData(actRadioData) {
this.activityRadioData = actRadioData;
},
/**
* Sets the activity radio global state for either the start ('From') or end ('To') of a task.
* We arrange in this way because backend needs us to communicate in this way.
* @param {object} actRadioData
* @param {string} fromToStr 'From' or 'To'
*/
setActivityRadioStartEndData(actRadioData, fromToStr){
switch(fromToStr) {
case 'From':
this.activityRadioData.task[0] = actRadioData;
break;
case 'To':
this.activityRadioData.task[this.activityRadioData.task.length - 1] = actRadioData;
break;
default:
break;
}
},
/**
* UNUSED
* Temporarily set conformance input data which is probably fed to backend later.
* @param {object} userInputObj
*/
setConformanceUserInput(userInputObj){
this.inputDataToSave = {...userInputObj};
},
/** UNUSED
* Set the starting time of time range to be saved later
* @param {string} startStr
*/
setConformanceInputStart(startStr){
this.inputDataToSave.inputStart = moment(startStr).format('YYYY-MM-DDTHH:mm:ss');
},
/** UNUSED
* Set the ending time of time range to be saved later
* @param {string} startStr
*/
setConformanceInputEnd(endStr){
this.inputDataToSave.inputEnd = moment(endStr).format('YYYY-MM-DDTHH:mm:ss');
},
},
})