mirror of
https://github.com/frappe/books.git
synced 2025-02-02 03:58:26 +00:00
fix(ux): allow party type on ambiguous quickedit
This commit is contained in:
parent
3ed5f40586
commit
71d55950ff
@ -1,5 +1,4 @@
|
||||
import frappe from 'frappe';
|
||||
import { t } from 'frappe';
|
||||
import frappe, { t } from 'frappe';
|
||||
|
||||
export default {
|
||||
name: 'Party',
|
||||
@ -21,12 +20,12 @@ export default {
|
||||
},
|
||||
{
|
||||
fieldname: 'customer',
|
||||
label: 'Customer',
|
||||
label: 'Is Customer',
|
||||
fieldtype: 'Check',
|
||||
},
|
||||
{
|
||||
fieldname: 'supplier',
|
||||
label: 'Supplier',
|
||||
label: 'Is Supplier',
|
||||
fieldtype: 'Check',
|
||||
},
|
||||
{
|
||||
|
@ -14,6 +14,10 @@ export default class PartyServer extends BaseDocument {
|
||||
throw new Error();
|
||||
}
|
||||
|
||||
if (!this.customer && !this.supplier) {
|
||||
this.supplier = 1;
|
||||
}
|
||||
|
||||
if (this.gstin && ['Unregistered', 'Consumer'].includes(this.gstType)) {
|
||||
this.gstin = '';
|
||||
}
|
||||
|
@ -84,14 +84,11 @@ import StatusBadge from '@/components/StatusBadge';
|
||||
import FormControl from '@/components/Controls/FormControl';
|
||||
import TwoColumnForm from '@/components/TwoColumnForm';
|
||||
import DropdownWithActions from '@/components/DropdownWithActions';
|
||||
import {
|
||||
openQuickEdit,
|
||||
getActionsForDocument,
|
||||
} from '@/utils';
|
||||
import { openQuickEdit, getActionsForDocument } from '@/utils';
|
||||
|
||||
export default {
|
||||
name: 'QuickEditForm',
|
||||
props: ['doctype', 'name', 'values', 'hideFields'],
|
||||
props: ['doctype', 'name', 'values', 'hideFields', 'showFields'],
|
||||
components: {
|
||||
Button,
|
||||
FormControl,
|
||||
@ -126,14 +123,23 @@ export default {
|
||||
},
|
||||
status() {
|
||||
if (this.doc && this.doc._notInserted) {
|
||||
return "Draft";
|
||||
return 'Draft';
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
},
|
||||
fields() {
|
||||
return this.meta
|
||||
const fields = this.meta
|
||||
.getQuickEditFields()
|
||||
.filter((df) => !(this.hideFields || []).includes(df.fieldname));
|
||||
|
||||
if (this.showFields) {
|
||||
fields.push(
|
||||
...this.meta.fields.filter(({ fieldname }) =>
|
||||
this.showFields.includes(fieldname)
|
||||
)
|
||||
);
|
||||
}
|
||||
return fields;
|
||||
},
|
||||
actions() {
|
||||
return getActionsForDocument(this.doc);
|
||||
@ -204,7 +210,7 @@ export default {
|
||||
await this.$refs.form.submit();
|
||||
} catch (e) {
|
||||
this.statusText = null;
|
||||
console.error(e)
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
routeToPrevious() {
|
||||
|
16
src/utils.js
16
src/utils.js
@ -120,7 +120,20 @@ export function partyWithAvatar(party) {
|
||||
};
|
||||
}
|
||||
|
||||
export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) {
|
||||
function getShowFields(doctype) {
|
||||
if (doctype === 'Party') {
|
||||
return ['customer'];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
export function openQuickEdit({
|
||||
doctype,
|
||||
name,
|
||||
hideFields,
|
||||
showFields,
|
||||
defaults = {},
|
||||
}) {
|
||||
let currentRoute = router.currentRoute;
|
||||
let query = currentRoute.query;
|
||||
let method = 'push';
|
||||
@ -135,6 +148,7 @@ export function openQuickEdit({ doctype, name, hideFields, defaults = {} }) {
|
||||
edit: 1,
|
||||
doctype,
|
||||
name,
|
||||
showFields: showFields ?? getShowFields(doctype),
|
||||
hideFields,
|
||||
values: defaults,
|
||||
lastRoute: currentRoute,
|
||||
|
Loading…
x
Reference in New Issue
Block a user