Comments (1)
I switched to this approach so my default values are applied when the form is set up.
The settings are applied locally and not pushed to the server.
This way, if the user hasn't set their own settings, they will always use my default config.
const defaultColumnSettings = [
{'fieldname':'item_code','columns':1},
// ... more columns
];
frappe.ui.form.on('Quotation', {
setup(frm) {
const settings = frappe.model.user_settings['Quotation'];
if (settings.GridView?.['Quotation Item'] != null) return;
settings.GridView = settings.GridView || {};
settings.GridView['Quotation Item'] = defaultColumnSettings;
}
});
I also tried hooking somehow to the "Reset to default" button somehow, so the user doesn't need to refresh the page to see my defaults.
I couldn't find a good way, so I switched to make the settings object reactive with Vue
frappe.ui.form.on('Quotation', {
setup(frm) {
// Make 'user_settings' reactive
if (!Vue.isReactive(frappe.model.user_settings))
frappe.model.user_settings = Vue.shallowReactive(frappe.model.user_settings);
Vue.watch(
() => frappe.model.user_settings.Quotation,
(settings) => {
if (settings.GridView?.['Quotation Item'] != null) return;
settings.GridView = v.GridView || {};
settings.GridView['Quotation Item'] = defaultColumnSettings;
},
{ immediate: true }
);
}
});
from frappe.
Related Issues (20)
- [BUG] adding child table in web form has permission issue "You are not permitted to access this resource"
- The phone number in Contact Phone Doctype should be of type Phone. HOT 1
- Unit testing framework is down ? HOT 1
- Mandatory field red mark is not align in Mobile View
- Saved as reports (Report Builder) should have option to allow only for "Owner"
- feat: combine filters for views (or/and ...)
- feat: global search
- Replacement for wkhtmltopdf dep HOT 2
- Text Editor Space Issues
- Google Calendar sync fails when event ID is too long
- Permission Denied for Schema Public Error in PostgreSQL (Version 15) HOT 2
- frappe.db.set_value modifies all existing docs when passing a object as name
- Open Links in New Tab For Communications
- Undo Email
- Imporved Desk Workspace Sidebar Menu
- DeprecationWarning HOT 1
- AttributeError in System Health Report: Missing Attribute ‘oldest_unscheduled_job’ HOT 3
- Login with Social Login doesn't redirect to FRAPPE_SITE_NAME_HEADER
- Undefined value in search results HOT 1
- List View Settings bug: total_fields has wrong value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from frappe.