fix UI & add unchanged

This commit is contained in:
xue jiahao
2024-12-23 23:08:55 +08:00
parent 57af07ba73
commit 972bbf9013
6 changed files with 46 additions and 33 deletions

View File

@@ -1,12 +1,17 @@
<template> <template>
<q-input <q-input
ref="nameRef"
v-model="versionInfo.name" v-model="versionInfo.name"
filled filled
autofocus autofocus
label="バージョン名" label="バージョン名"
:rules="[(val) => !val || val.length <= 80 || '80字以内で入力ください']" :rules="[
val => !!val || 'バージョン名を入力してください。',
(val) => !val || val.length <= 80 || '80字以内で入力ください'
]"
/> />
<q-input <q-input
ref="commentRef"
v-model="versionInfo.comment" v-model="versionInfo.comment"
filled filled
type="textarea" type="textarea"
@@ -19,6 +24,15 @@ import { ref, watch, defineProps, defineEmits } from 'vue';
import { QInput } from 'quasar'; import { QInput } from 'quasar';
import { IVersionSubmit } from 'src/types/AppTypes'; import { IVersionSubmit } from 'src/types/AppTypes';
const nameRef = ref();
const commentRef = ref();
const isValid = () => {
const nameHasError = nameRef.value?.hasError ?? false;
const commentHasError = commentRef.value?.hasError ?? false;
return !nameHasError && !commentHasError;
};
const props = defineProps<{ const props = defineProps<{
modelValue: IVersionSubmit; modelValue: IVersionSubmit;
}>(); }>();
@@ -33,6 +47,10 @@ const versionInfo = ref({
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
defineExpose({
isValid
})
watch( watch(
versionInfo, versionInfo,
() => { () => {

View File

@@ -31,7 +31,8 @@
<template v-slot:body-cell-version="p"> <template v-slot:body-cell-version="p">
<q-td :props="p"> <q-td :props="p">
<div class="flex justify-between full-width" > <div class="flex justify-between full-width" >
<span class="ellipsis" :title="p.row.versionName">{{ p.row.versionName || '未命名' }}</span> <span v-if="p.row.version == 0"></span>
<span v-else class="ellipsis" :title="p.row.versionName">{{ p.row.versionName }}</span>
<q-badge v-if="isVersionEditing(p.row)" color="orange-7">変更あり</q-badge> <q-badge v-if="isVersionEditing(p.row)" color="orange-7">変更あり</q-badge>
</div> </div>
</q-td> </q-td>
@@ -128,9 +129,8 @@ const getApps = async () => {
loading.value = false; loading.value = false;
} }
function isVersionEditing(app:IAppDisplay) { function isVersionEditing(app: IAppDisplay) {
// TODO return !!app.versionChanged;
return false;
}; };
onMounted(async () => { onMounted(async () => {

View File

@@ -32,7 +32,7 @@
<div class=""> <div class="">
<span>{{ p.row.id }}</span> <span>{{ p.row.id }}</span>
<span class="q-ml-md" v-if="p.row.id === app.version"> <span class="q-ml-md" v-if="p.row.id === app.version">
<q-badge color="primary">適用中</q-badge> <q-badge color="primary">適用中</q-badge>
<q-badge class="q-ml-xs" v-if="isVersionEditing()" color="orange-7">変更あり</q-badge> <q-badge class="q-ml-xs" v-if="isVersionEditing()" color="orange-7">変更あり</q-badge>
</span> </span>
</div> </div>
@@ -58,19 +58,17 @@
</template> </template>
</q-table> </q-table>
<q-dialog v-model="confirmDialog" persistent> <q-dialog v-model="confirmDialog" persistent>
<q-card> <q-card>
<q-card-section class="q-pb-none"> <q-card-section class="q-pb-none">
<q-list> <q-list>
<q-item> <q-item class="q-px-none">
<q-item-section avatar> <q-item-section avatar class="items-center">
<q-icon name="warning" color="warning" size="2em" /> <q-icon name="warning" color="warning" size="2em" />
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<div >現在のバージョンは未保存です</div> <div>現在のバージョンは未保存です</div>
<div >プルすると上書されますのでよろしいでしょうか</div> <div>プルすると上書されますのでよろしいでしょうか</div>
</q-item-section> </q-item-section>
</q-item> </q-item>
</q-list> </q-list>
@@ -90,7 +88,6 @@ import { useQuasar } from 'quasar';
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { useAppStore } from 'stores/useAppStore'; import { useAppStore } from 'stores/useAppStore';
import { useAuthStore } from 'stores/useAuthStore'; import { useAuthStore } from 'stores/useAuthStore';
import { useFlowEditorStore } from 'stores/flowEditor';
import { router } from 'src/router'; import { router } from 'src/router';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { IAppDisplay, IAppVersionDisplay } from 'src/types/AppTypes'; import { IAppDisplay, IAppVersionDisplay } from 'src/types/AppTypes';
@@ -121,7 +118,6 @@ const filter = ref('');
const versionLoading = ref(false); const versionLoading = ref(false);
const target = ref<IAppVersionDisplay>(); const target = ref<IAppVersionDisplay>();
const store = useFlowEditorStore();
const confirmDialog = ref(false); const confirmDialog = ref(false);
const deleteUserLoading = ref(false); const deleteUserLoading = ref(false);
@@ -152,8 +148,7 @@ const getVersions = async () => {
} }
function isVersionEditing() { function isVersionEditing() {
// TODO return !!app.value.versionChanged;
return false;
}; };
onMounted(async () => { onMounted(async () => {
@@ -195,18 +190,6 @@ async function doChangeVersion(version?: IAppVersionDisplay) {
versionLoading.value = false; versionLoading.value = false;
} }
async function toEditFlowPage() {
store.setApp({
appId: app.value.id,
name: app.value.name
});
store.selectFlow(undefined);
try {
await router.push('/FlowChart/' + app.value.id);
} catch (e) {
console.log(e);
}
};
</script> </script>
<style lang="scss"> <style lang="scss">

View File

@@ -85,8 +85,8 @@
<action-select ref="appDg" name="model" :filter="filter" type="single" @clearFilter="onClearFilter" ></action-select> <action-select ref="appDg" name="model" :filter="filter" type="single" @clearFilter="onClearFilter" ></action-select>
</ShowDialog> </ShowDialog>
<!-- save version dialog --> <!-- save version dialog -->
<ShowDialog v-model:visible="saveVersionAction" name="保存して新バージョン" @close="closeSaveVersionDg" min-width="500px"> <ShowDialog v-model:visible="saveVersionAction" name="保存して新バージョン" @close="closeSaveVersionDg" :ok-btn-auto-close="false" min-width="500px">
<version-input v-model="versionSubmit" /> <version-input ref="versionInputRef" v-model="versionSubmit" />
</ShowDialog> </ShowDialog>
<q-inner-loading <q-inner-loading
:showing="initLoading" :showing="initLoading"
@@ -135,6 +135,7 @@ const prevNodeIfo = ref({
// const refFlow = ref<ActionFlow|null>(null); // const refFlow = ref<ActionFlow|null>(null);
const showAddAction = ref(false); const showAddAction = ref(false);
const saveVersionAction = ref(false); const saveVersionAction = ref(false);
const versionInputRef = ref();
const drawerRight = ref(false); const drawerRight = ref(false);
const filter=ref(""); const filter=ref("");
const model = ref(""); const model = ref("");
@@ -270,9 +271,17 @@ const onSaveVersion = async () => {
} }
const closeSaveVersionDg = async (val: 'OK'|'CANCEL') => { const closeSaveVersionDg = async (val: 'OK'|'CANCEL') => {
saveVersionAction.value = true;
if (val == 'OK') { if (val == 'OK') {
await onSaveAllFlow(); if (versionInputRef?.value?.isValid()) {
await appStore.createVersion(versionSubmit.value); saveVersionAction.value = false;
await onSaveAllFlow();
await appStore.createVersion(versionSubmit.value);
} else {
saveVersionAction.value = true;
}
} else {
saveVersionAction.value = false;
} }
} }

View File

@@ -97,7 +97,8 @@ function appToAppDisplay(app: IManagedApp) {
version: app.version, version: app.version,
versionName: app.versionname, versionName: app.versionname,
updateTime: formatDate(app.update_time), updateTime: formatDate(app.update_time),
updateUser: userToUserDisplay(app.updateuser) updateUser: userToUserDisplay(app.updateuser),
versionChanged: app.is_saved
} as IAppDisplay } as IAppDisplay
} }

View File

@@ -10,6 +10,7 @@ export interface IManagedApp {
updateuser: IUser; updateuser: IUser;
create_time: string; create_time: string;
update_time: string; update_time: string;
is_saved: boolean;
} }
export interface IAppDisplay{ export interface IAppDisplay{
@@ -21,6 +22,7 @@ export interface IAppDisplay{
updateTime:string; updateTime:string;
version:number; version:number;
versionName?: string; versionName?: string;
versionChanged: boolean;
} }
export interface IVersionSubmit { export interface IVersionSubmit {