refactor: removed is_custom getter & refactored code accordingly

This commit is contained in:
Shariq Ansari 2022-10-28 21:48:32 +05:30
parent 601062e7fd
commit bb0e28937b
6 changed files with 9 additions and 15 deletions

View file

@ -19,7 +19,7 @@ function add_column() {
}
function remove_column() {
if (store.is_customize_form && store.is_custom(props.column) == 0) {
if (store.is_customize_form && props.column.df.is_custom_field == 0) {
frappe.msgprint(__("Cannot delete standard field. You can hide it if you want"));
throw "cannot delete standard field";
}
@ -97,7 +97,7 @@ function remove_column() {
<Field
:column="column"
:field="element"
:data-is-custom="store.is_custom(element)"
:data-is-custom="element.df.is_custom_field"
/>
</template>
</draggable>

View file

@ -10,7 +10,7 @@ let editing = ref(false);
let hovered = ref(false);
function remove_field() {
if (store.is_customize_form && store.is_custom(props.field) == 0) {
if (store.is_customize_form && props.field.df.is_custom_field == 0) {
frappe.msgprint(__("Cannot delete standard field. You can hide it if you want"));
throw "cannot delete standard field";
}

View file

@ -72,7 +72,7 @@ onMounted(() => store.fetch());
}
}
:deep([data-is-custom="1"]) {
:deep([data-has-std-field="false"]), :deep([data-is-custom="1"]) {
background-color: var(--yellow-highlight-color);
}
}

View file

@ -102,7 +102,7 @@ function remove_section() {
<Column
:section="section"
:column="element"
:data-is-custom="store.is_custom(element)"
:data-is-custom="element.df.is_custom_field"
:data-has-std-field="store.has_standard_field(element)"
/>
</template>
@ -115,13 +115,14 @@ function remove_section() {
<style lang="scss" scoped>
.form-section-container {
border-bottom: 1px solid var(--border-color);
background-color: var(--fg-color);
&:last-child {
border-bottom: none;
}
.form-section {
background-color: var(--fg-color);
background-color: inherit;
border: 1px solid transparent;
border-radius: var(--border-radius);
padding: 1rem;

View file

@ -120,7 +120,7 @@ function remove_tab() {
<div
:class="['tab', store.active_tab == element.df.name ? 'active' : '']"
:title="element.df.fieldname"
:data-is-custom="store.is_custom(element)"
:data-is-custom="element.df.is_custom_field"
:data-has-std-field="store.has_standard_field(element)"
@click.stop="activate_tab(element)"
@dragstart="dragged = true"
@ -175,7 +175,7 @@ function remove_tab() {
<Section
:tab="tab"
:section="element"
:data-is-custom="store.is_custom(element)"
:data-is-custom="element.df.is_custom_field"
:data-has-std-field="store.has_standard_field(element)"
/>
</template>

View file

@ -34,13 +34,6 @@ export const useStore = defineStore("store", {
return df;
};
},
is_custom: (state) => {
return (field) => {
if (!state.is_customize_form) return;
if (field.is_first) return 0;
return field.df.is_custom_field;
};
},
has_standard_field: (state) => {
return (field) => {
if (!state.is_customize_form) return;