Skip to content

Commit

Permalink
fix: filter supported fieldtypes on server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal committed Aug 27, 2023
1 parent 39ffe9e commit ed009af
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
19 changes: 1 addition & 18 deletions frontend/src/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,31 +151,14 @@ const props = defineProps({
const emit = defineEmits(["change", "update:modelValue"])
const dayjs = inject("$dayjs")
const SUPPORTED_FIELD_TYPES = [
"Link",
"Select",
"Small Text",
"Text",
"Long Text",
"Text Editor",
"Check",
"Data",
"Float",
"Int",
"Section Break",
"Date",
"Time",
"Datetime",
"Currency",
]
let linkFieldList = ref([])
let date = ref(null)
const showField = computed(() => {
if (props.readOnly && !isLayoutField.value && !props.modelValue) return false
return SUPPORTED_FIELD_TYPES.includes(props.fieldtype) && !props.hidden
return props.fieldtype !== "Table" && !props.hidden
})
const isNumberType = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/FormView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
:errorMessage="field.error_message"
:minDate="field.minDate"
:maxDate="field.maxDate"
:addSectionPadding="fieldList[1].name !== field.name"
:addSectionPadding="fieldList[0].name !== field.name"
/>
</template>

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/salary_slip/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function getPeriodLabel(period) {
watch(
() => selectedPeriod.value,
(value) => {
let period = periodsByName.value[value.value]
let period = periodsByName.value[value?.value]
documents.filters.start_date = [
"between",
[period?.start_date, period?.end_date],
Expand Down
26 changes: 25 additions & 1 deletion hrms/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
from frappe.query_builder.functions import Count
from frappe.utils import getdate

SUPPORTED_FIELD_TYPES = [
"Link",
"Select",
"Small Text",
"Text",
"Long Text",
"Text Editor",
"Table",
"Check",
"Data",
"Float",
"Int",
"Section Break",
"Date",
"Time",
"Datetime",
"Currency",
]


@frappe.whitelist()
def get_current_user_info() -> dict:
Expand Down Expand Up @@ -405,7 +424,12 @@ def get_company_cost_center(company: str) -> str:
# Form View APIs
@frappe.whitelist()
def get_doctype_fields(doctype: str) -> list[dict]:
return frappe.get_meta(doctype).fields
fields = frappe.get_meta(doctype).fields
return [
field
for field in fields
if field.fieldtype in SUPPORTED_FIELD_TYPES and field.fieldname != "amended_from"
]


@frappe.whitelist()
Expand Down

0 comments on commit ed009af

Please sign in to comment.