feat(minor): Build Workspace, renamed frappe.views.Views => frappe.views.ListViewSelect, fixed recurring dependency issue on grids

This commit is contained in:
Rushabh Mehta 2021-01-02 14:04:32 +05:30
parent 6bfd482032
commit 72a28547ea
15 changed files with 242 additions and 17 deletions

4
.gitignore vendored
View file

@ -7,7 +7,7 @@ locale
*.swp *.swp
*.egg-info *.egg-info
dist/ dist/
build/ # build/
frappe/docs/current frappe/docs/current
.vscode .vscode
node_modules node_modules
@ -28,7 +28,7 @@ __pycache__/
# Distribution / packaging # Distribution / packaging
.Python .Python
build/ # build/
develop-eggs/ develop-eggs/
dist/ dist/
downloads/ downloads/

View file

@ -14,8 +14,8 @@ context('List View Settings', () => {
cy.wait(300); cy.wait(300);
cy.get('.list-count').should('contain', "20 of"); cy.get('.list-count').should('contain', "20 of");
cy.get('.menu-btn-group button').click(); cy.get('.menu-btn-group button').click();
cy.get('.dropdown-menu li').filter(':visible').contains('Settings').click(); cy.get('.dropdown-menu li').filter(':visible').contains('List Settings').click();
cy.get('.modal-dialog').should('contain', 'Settings'); cy.get('.modal-dialog').should('contain', 'List Settings');
cy.get('input[data-fieldname="disable_count"]').check({ force: true }); cy.get('input[data-fieldname="disable_count"]').check({ force: true });
cy.get('input[data-fieldname="disable_sidebar_stats"]').check({ force: true }); cy.get('input[data-fieldname="disable_sidebar_stats"]').check({ force: true });
@ -27,8 +27,8 @@ context('List View Settings', () => {
cy.get('.list-sidebar .list-tags').should('not.exist'); cy.get('.list-sidebar .list-tags').should('not.exist');
cy.get('.menu-btn-group button').click({ force: true }); cy.get('.menu-btn-group button').click({ force: true });
cy.get('.dropdown-menu li').filter(':visible').contains('Settings').click(); cy.get('.dropdown-menu li').filter(':visible').contains('List Settings').click();
cy.get('.modal-dialog').should('contain', 'Settings'); cy.get('.modal-dialog').should('contain', 'List Settings');
cy.get('input[data-fieldname="disable_count"]').uncheck({ force: true }); cy.get('input[data-fieldname="disable_count"]').uncheck({ force: true });
cy.get('input[data-fieldname="disable_sidebar_stats"]').uncheck({ force: true }); cy.get('input[data-fieldname="disable_sidebar_stats"]').uncheck({ force: true });
cy.get('button').filter(':visible').contains('Save').click(); cy.get('button').filter(':visible').contains('Save').click();

View file

@ -0,0 +1,211 @@
{
"cards_label": "Elements",
"category": "Modules",
"charts": [],
"creation": "2021-01-02 10:51:16.579957",
"developer_mode_only": 0,
"disable_user_customization": 0,
"docstatus": 0,
"doctype": "Workspace",
"extends_another_page": 0,
"hide_custom": 0,
"icon": "tool",
"idx": 0,
"is_standard": 1,
"label": "Build",
"links": [
{
"hidden": 0,
"is_query_report": 0,
"label": "Modules",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Card Break"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Module Def",
"link_to": "Module Def",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Workspace",
"link_to": "Workspace",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Module Onboarding",
"link_to": "Module Onboarding",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Block Module",
"link_to": "Block Module",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Models",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Card Break"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "DocType",
"link_to": "DocType",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Workflow",
"link_to": "Workflow",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Views",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Card Break"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Report",
"link_to": "Report",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Print Format",
"link_to": "Print Format",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Workspace",
"link_to": "Workspace",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Dashboard",
"link_to": "Dashboard",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Scripting",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Card Break"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Server Script",
"link_to": "Server Script",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Custom Script",
"link_to": "Custom Script",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
},
{
"hidden": 0,
"is_query_report": 0,
"label": "Scheduled Job Type",
"link_to": "Scheduled Job Type",
"link_type": "DocType",
"onboard": 0,
"only_for": "",
"type": "Link"
}
],
"modified": "2021-01-02 14:03:15.029699",
"modified_by": "Administrator",
"module": "Core",
"name": "Build",
"owner": "Administrator",
"pin_to_bottom": 0,
"pin_to_top": 0,
"shortcuts": [
{
"doc_view": "",
"label": "DocType",
"link_to": "DocType",
"type": "DocType"
},
{
"doc_view": "",
"label": "Workspace",
"link_to": "Workspace",
"type": "DocType"
},
{
"doc_view": "",
"label": "Report",
"link_to": "Report",
"type": "DocType"
}
]
}

View file

@ -2,6 +2,10 @@
// For license information, please see license.txt // For license information, please see license.txt
frappe.ui.form.on('Workspace', { frappe.ui.form.on('Workspace', {
setup: function(frm) {
frappe.meta.get_field('Desk Link', 'only_for').no_default = true;
},
refresh: function(frm) { refresh: function(frm) {
frm.enable_save(); frm.enable_save();
frm.get_field("is_standard").toggle(frappe.boot.developer_mode); frm.get_field("is_standard").toggle(frappe.boot.developer_mode);

View file

@ -42,6 +42,7 @@
}, },
{ {
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "charts",
"fieldname": "section_break_2", "fieldname": "section_break_2",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Dashboards" "label": "Dashboards"
@ -139,12 +140,14 @@
}, },
{ {
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "shortcuts",
"fieldname": "section_break_15", "fieldname": "section_break_15",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Shortcuts" "label": "Shortcuts"
}, },
{ {
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "links",
"fieldname": "section_break_18", "fieldname": "section_break_18",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Link Cards" "label": "Link Cards"
@ -206,7 +209,7 @@
} }
], ],
"links": [], "links": [],
"modified": "2020-12-01 13:36:26.827062", "modified": "2021-01-02 10:58:37.430775",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Desk", "module": "Desk",
"name": "Workspace", "name": "Workspace",

View file

@ -250,7 +250,7 @@
"public/js/frappe/list/list_view.js", "public/js/frappe/list/list_view.js",
"public/js/frappe/list/list_factory.js", "public/js/frappe/list/list_factory.js",
"public/js/frappe/list/views.js", "public/js/frappe/list/list_view_select.js",
"public/js/frappe/list/list_sidebar.js", "public/js/frappe/list/list_sidebar.js",
"public/js/frappe/list/list_sidebar.html", "public/js/frappe/list/list_sidebar.html",
"public/js/frappe/list/list_sidebar_stat.html", "public/js/frappe/list/list_sidebar_stat.html",

View file

@ -284,7 +284,7 @@ frappe.Application = Class.extend({
} }
if (!frappe.workspaces['home']) { if (!frappe.workspaces['home']) {
// default workspace is settings for Frappe // default workspace is settings for Frappe
frappe.workspaces['home'] = frappe.workspaces['settings']; frappe.workspaces['home'] = frappe.workspaces['build'];
} }
}, },

View file

@ -265,6 +265,8 @@ export default class Grid {
} }
refresh(force) { refresh(force) {
if (this.frm.setting_dependency) return;
this.data = this.get_data(); this.data = this.get_data();
!this.wrapper && this.make(); !this.wrapper && this.make();

View file

@ -510,7 +510,9 @@ frappe.ui.form.Layout = Class.extend({
} }
if (form_obj) { if (form_obj) {
if (this.doc && this.doc.parent) { if (this.doc && this.doc.parent) {
form_obj.setting_dependency = true;
form_obj.set_df_property(this.doc.parentfield, property, value, this.doc.parent, fieldname); form_obj.set_df_property(this.doc.parentfield, property, value, this.doc.parent, fieldname);
form_obj.setting_dependency = false;
} else { } else {
form_obj.set_df_property(fieldname, property, value); form_obj.set_df_property(fieldname, property, value);
} }

View file

@ -183,8 +183,9 @@ frappe.views.BaseList = class BaseList {
} }
if (frappe.boot.desk_settings.view_switcher) { if (frappe.boot.desk_settings.view_switcher) {
this.views_menu = this.page.add_custom_button_group(__(`{0} View`, [this.view_name]), icon_map[this.view_name] || 'list'); this.views_menu = this.page.add_custom_button_group(__('{0} View', [this.view_name]),
this.views_list = new frappe.views.Views({ icon_map[this.view_name] || 'list');
this.views_list = new frappe.views.ListViewSelect({
doctype: this.doctype, doctype: this.doctype,
parent: this.views_menu, parent: this.views_menu,
page: this.page, page: this.page,

View file

@ -1,7 +1,7 @@
export default class ListSettings { export default class ListSettings {
constructor({ listview, doctype, meta, settings }) { constructor({ listview, doctype, meta, settings }) {
if (!doctype) { if (!doctype) {
frappe.throw(__('Doctype required')); frappe.throw('DocType required');
} }
this.listview = listview; this.listview = listview;

View file

@ -1485,7 +1485,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
if (frappe.user.has_role("System Manager")) { if (frappe.user.has_role("System Manager")) {
items.push({ items.push({
label: __("Settings"), label: __("List Settings"),
action: () => this.show_list_settings(), action: () => this.show_list_settings(),
standard: true, standard: true,
}); });

View file

@ -1,6 +1,7 @@
frappe.provide('frappe.views'); frappe.provide('frappe.views');
frappe.views.Views = class Views { frappe.views.ListViewSelect = class ListViewSelect
{
constructor(opts) { constructor(opts) {
$.extend(this, opts); $.extend(this, opts);
this.set_current_view(); this.set_current_view();

View file

@ -87,11 +87,12 @@ $.extend(frappe.model, {
var doctype = doc.doctype; var doctype = doc.doctype;
var docfields = frappe.meta.get_docfields(doctype); var docfields = frappe.meta.get_docfields(doctype);
var updated = []; var updated = [];
for(var fid=0;fid<docfields.length;fid++) { for (var fid=0;fid<docfields.length;fid++) {
var f = docfields[fid]; var f = docfields[fid];
if(!in_list(frappe.model.no_value_type, f.fieldtype) && doc[f.fieldname]==null) { if(!in_list(frappe.model.no_value_type, f.fieldtype) && doc[f.fieldname]==null) {
if (f.no_default) continue;
var v = frappe.model.get_default_value(f, doc, parent_doc); var v = frappe.model.get_default_value(f, doc, parent_doc);
if(v) { if (v) {
if(in_list(["Int", "Check"], f.fieldtype)) if(in_list(["Int", "Check"], f.fieldtype))
v = cint(v); v = cint(v);
else if(in_list(["Currency", "Float"], f.fieldtype)) else if(in_list(["Currency", "Float"], f.fieldtype))

View file

@ -69,7 +69,7 @@ frappe.views.Workspace = class Workspace {
} else if (frappe.boot.allowed_workspaces) { } else if (frappe.boot.allowed_workspaces) {
default_page = frappe.boot.allowed_workspaces[0].name; default_page = frappe.boot.allowed_workspaces[0].name;
} else { } else {
default_page = "Settings"; default_page = "Build";
} }
let page = frappe.get_route()[1] || default_page; let page = frappe.get_route()[1] || default_page;