Skip to content

Commit

Permalink
Fixed reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Severino committed Aug 6, 2024
1 parent 46d6301 commit 3c224e0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 50 deletions.
54 changes: 27 additions & 27 deletions resources/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export async function removePlugin(id) {
}

export async function fetchEntityMetadata(id) {
const {data} = await $httpQueue.add(() => http.get(`entity/${id}/metadata`));
store.dispatch('updateEntityMetadata', {eid: id, data});
const { data } = await $httpQueue.add(() => http.get(`entity/${id}/metadata`));
store.dispatch('updateEntityMetadata', { eid: id, data });
return data;
}

Expand Down Expand Up @@ -270,7 +270,7 @@ async function fetchComments(id, type, aid = null) {
if(!!aid) {
endpoint = `${endpoint}&aid=${aid}`;
}
return $httpQueue.add(() => http.get(endpoint).then(response => response.data).catch(error => {throw error;}));
return $httpQueue.add(() => http.get(endpoint).then(response => response.data).catch(error => { throw error; }));
}

export async function exportBibtexFile(selection) {
Expand Down Expand Up @@ -358,7 +358,7 @@ export async function resetUserPassword(uid, password) {
}

export async function confirmUserPassword(uid, password = null) {
const data = !!password ? {password: password} : {};
const data = !!password ? { password: password } : {};
return $httpQueue.add(
() => http.patch(`user/${uid}/password/confirm`, data).then(response => response.data)
);
Expand Down Expand Up @@ -482,7 +482,7 @@ export async function duplicateEntity(entity) {

export async function importEntityData(data) {
return $httpQueue.add(
() => http.post(`/entity/import`, data).then(response => response.data).catch(e => {throw e;})
() => http.post(`/entity/import`, data).then(response => response.data).catch(e => { throw e; })
);
}

Expand Down Expand Up @@ -525,29 +525,29 @@ export async function addAttribute(attribute) {
data.restricted_types = attribute.restrictedTypes.map(t => t.id);
}
if(attribute.columns && attribute.columns.length > 0) {
data.columns = attribute.columns.map(c => {
const mappedC = {...c};
if(mappedC.label) {
mappedC.label_id = mappedC.label.id;
delete mappedC.label;
data.columns = attribute.columns.map(column => {
const mappedColumn = { ...column };
if(mappedColumn.label) {
mappedColumn.label_id = mappedColumn.label.id;
delete mappedColumn.label;
}
if(mappedC.rootLabel) {
mappedC.root_id = mappedC.rootLabel.id;
delete mappedC.rootLabel;
if(mappedColumn.rootLabel) {
mappedColumn.root_id = mappedColumn.rootLabel.id;
delete mappedColumn.rootLabel;
}
if(mappedC.restrictedTypes) {
mappedC.restricted_types = mappedC.restrictedTypes.map(t => t.id);
delete mappedC.restrictedTypes;
if(mappedColumn.restrictedTypes) {
mappedColumn.restricted_types = mappedColumn.restrictedTypes.map(t => t.id);
delete mappedColumn.restrictedTypes;
}
if(mappedC.siGroup) {
mappedC.si_base = mappedC.siGroup;
mappedC.si_default = mappedC.siGroupUnit;
delete mappedC.siGroup;
delete mappedC.siGroupUnit;
if(mappedColumn.siGroup) {
mappedColumn.si_base = mappedColumn.siGroup;
mappedColumn.si_default = mappedColumn.siGroupUnit;
delete mappedColumn.siGroup;
delete mappedColumn.siGroupUnit;
}
mappedC.datatype = mappedC.type;
delete mappedC.type;
return mappedC;
mappedColumn.datatype = mappedColumn.type;
delete mappedColumn.type;
return mappedColumn;
});
}
if(attribute.textContent) {
Expand Down Expand Up @@ -640,7 +640,7 @@ export async function patchEntityName(eid, name) {

export async function patchEntityMetadata(eid, metadata) {
return $httpQueue.add(
() => http.patch(`entity/${eid}/metadata`, metadata).then(response => response.data).catch(error => {throw error;})
() => http.patch(`entity/${eid}/metadata`, metadata).then(response => response.data).catch(error => { throw error; })
);
}

Expand All @@ -652,7 +652,7 @@ export async function patchAttribute(entityId, attributeId, data) {

export async function patchAttributes(entityId, data) {
return $httpQueue.add(
() => http.patch(`/entity/${entityId}/attributes`, data).then(response => response.data).catch(error => {throw error;})
() => http.patch(`/entity/${entityId}/attributes`, data).then(response => response.data).catch(error => { throw error; })
);
}

Expand Down Expand Up @@ -681,7 +681,7 @@ export async function handleModeration(modAction, entity_id, attribute_id, overw
});
}
return response.data;
}).catch(error => {throw error;})
}).catch(error => { throw error; })
);
}

Expand Down
11 changes: 6 additions & 5 deletions resources/js/components/attribute/Attribute.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@
import {
getAttributeSelection,
getEmptyAttributeValue,
_cloneDeep,
} from '@/helpers/helpers.js';
import StringAttr from '@/components/attribute/String.vue';
Expand Down Expand Up @@ -357,12 +358,16 @@
disabled,
} = toRefs(props);
// FETCH
const getValueOrDefault = _ => {
return valueWrapper.value.value || getEmptyAttributeValue(data.value.datatype);
};
const attrRef = ref({});
const state = reactive({
type: computed(_ => data.value.datatype),
disabled: computed(_ => data.value.isDisabled || disabled.value),
value: computed(_ => getValueOrDefault()),
value: _cloneDeep(getValueOrDefault()),
// TODO check for selection need?
selection: computed(_ => getAttributeSelection(data.value.id) || []),
Expand Down Expand Up @@ -397,10 +402,6 @@
}
};
const getValueOrDefault = _ => {
return valueWrapper.value.value || getEmptyAttributeValue(state.type);
};
const undirtyField = _ => {
if(attrRef.value && attrRef.value.undirtyField) {
attrRef.value.undirtyField();
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/attribute/Entity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:disabled="disabled"
@selected="e => entitySelected(e)"
@entry-click="e => entryClicked(e)"
@deselect="v.handleChange(null)"
/>
<router-link
v-if="canShowLink"
Expand Down
8 changes: 4 additions & 4 deletions resources/js/components/attribute/SingleChoice.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<template>
f<template>
<multiselect
v-model="v.value"
:classes="multiselectResetClasslist"
Expand Down Expand Up @@ -179,9 +179,9 @@
};
const formatAndHandleChange = value => {
return veeHandleChange(
formatValue(value)
);
if(value != null)
value = formatValue(value);
return veeHandleChange(value);
};
const setSearchQuery = query => {
Expand Down
15 changes: 1 addition & 14 deletions resources/js/components/attribute/Tabular.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,6 @@
export default {
components: {
// 'string-attribute': StringAttr,
// 'integer-attribute': IntegerAttr,
// 'float-attribute': FloatAttr,
// 'bool-attribute': Bool,
// 'iconclass-attribute': Iconclass,
// 'rism-attribute': RISM,
// 'entity-attribute': Entity,
// 'date-attribute': DateAttr,
// 'daterange-attribute': DaterangeAttr,
// 'singlechoice-attribute': SingleChoice,
// 'multichoice-attribute': MultiChoice,
// 'userlist-attribute': UserList,
// 'url-attribute': Url,
Row,
},
props: {
Expand Down Expand Up @@ -305,7 +292,7 @@
return idx;
// return hash(JSON.stringify(row)) + idx;
};
const resetFieldState = _ => {
const resetFieldState = _ => {
v.resetField({
value: value.value
});
Expand Down

0 comments on commit 3c224e0

Please sign in to comment.