Skip to content

Commit

Permalink
Merge pull request #517 from frappe/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik authored Jan 6, 2025
2 parents 4b24cc7 + 66899bc commit 03e5365
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 33 deletions.
37 changes: 6 additions & 31 deletions frontend/src/components/Settings/SettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
:data="data.doc"
:doctype="doctype"
/>
<ErrorMessage class="mt-2" :message="error" />
</div>
<div v-else class="flex flex-1 items-center justify-center">
<Spinner class="size-8" />
</div>
<div class="flex flex-row-reverse">
<div class="flex justify-between gap-2">
<div>
<ErrorMessage class="mt-2" :message="data.save.error" />
</div>
<Button
:loading="data.save.loading"
:label="__('Update')"
variant="solid"
@click="update"
@click="data.save.submit()"
/>
</div>
</div>
Expand All @@ -43,7 +45,7 @@ import {
ErrorMessage,
} from 'frappe-ui'
import { createToast, getRandom } from '@/utils'
import { ref, computed } from 'vue'
import { computed } from 'vue'
const props = defineProps({
doctype: {
Expand All @@ -70,8 +72,6 @@ const fields = createResource({
auto: true,
})
const error = ref(null)
const data = createDocumentResource({
doctype: props.doctype,
name: props.doctype,
Expand Down Expand Up @@ -148,29 +148,4 @@ const tabs = computed(() => {
return _tabs
})
function update() {
error.value = null
if (validateMandatoryFields()) return
data.save.submit()
}
function validateMandatoryFields() {
if (!tabs.value) return false
for (let section of tabs.value[0].sections) {
for (let column of section.columns) {
for (let field of column.fields) {
if (
(field.mandatory ||
(field.mandatory_depends_on && field.mandatory_via_depends_on)) &&
!data.doc[field.name]
) {
error.value = __('{0} is mandatory', [__(field.label)])
return true
}
}
}
}
return false
}
</script>
5 changes: 3 additions & 2 deletions frontend/src/components/SidePanelLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@
<div
class="w-[35%] min-w-20 shrink-0 truncate text-sm text-ink-gray-5"
>
<span>{{ __(field.label) }}</span>
{{ __(field.label) }}
<span
v-if="
field.reqd ||
(field.mandatory_depends_on &&
field.mandatory_via_depends_on)
"
class="text-ink-red-3"
> *</span>
>*</span
>
</div>
</Tooltip>
<div class="flex items-center justify-between w-[65%]">
Expand Down

0 comments on commit 03e5365

Please sign in to comment.