Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multicheck control] #4529

Merged
merged 11 commits into from Dec 6, 2017
Merged

[Multicheck control] #4529

merged 11 commits into from Dec 6, 2017

Conversation

pratu16x7
Copy link
Contributor

@pratu16x7 pratu16x7 commented Nov 23, 2017

Update (27-11-2017)

  • Value: JSON string array
  • Removed usage of Has Domain child table, and consequently the doctype.
  • get_checked_values() and get_unchecked_values(), though get_checked_values() is semantically the parsed value of the control itself.

Will affect: frappe/erpnext#11709

UI: multiple checkboxes
Value: Comma-separated string of values
Options: Array of label/value option objects

  • Came across three different use cases, replaced.

  • Name bad, but multiselect already exists.

  • No doctype option even though most of time it would fetch a document name list, to decouple the getting data operation. Handles async fetches.

  • select_all optional

  • Check box editor removed, functionality covered except the one of mapping values to child tables, instead implemented when needed, as in Domain Settings (important enough to be abstracted as before?)

  • Comma-separation followed from the multiselect control, now I think a parsable JSON array should be used.

screen shot 2017-11-23 at 8 46 04 pm
screen shot 2017-11-23 at 9 05 22 pm

Value updates:
multi_check_field
screen shot 2017-11-23 at 8 47 39 pm

@netchampfaris
Copy link
Contributor

Comma-separation followed from the multiselect control, now I think a parsable JSON array should be used.

Yes, please.

this.setup_select_all();
}
},

Copy link
Member

@rmehta rmehta Nov 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be good to have helper methods get_checked and get_unchecked

also implement change event

@pratu16x7
Copy link
Contributor Author

  • Value: JSON string array
  • Removed usage of Has Domain child table, and consequently the doctype.
  • get_checked_values() and get_unchecked_values(), though get_checked_values() is semantically the parsed value of the control itself.

},

get_checked_options() {
return JSON.parse(this.selected_options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why store in JSON and not native objects?

self.save()

def on_update(self):
for d in self.active_domains:
domain = frappe.get_doc('Domain', d.domain)
for d in json.loads(self.active_domains):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be handled in client side. server has nothing to do with controls!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe we could parse Multi Check control values as list by default ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, had tried to set their value as a list itself, but wasn't sure how we'd store the field value in the database then.

@@ -41,6 +41,14 @@ frappe.utils = {
is_md: function() {
return $(document).width() < 1199 && $(document).width() >= 991;
},
is_json_string: function(str) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_json


get_select_buttons() {
return $(`<div><button class="btn btn-xs btn-default select-all"
style="margin-right: 5px;">${__("Select All")}</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

styling in controls.less ?


get_checkbox_element(option) {
return $(`
<div class="checkbox unit-checkbox" style="color: #36414c;">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

styling in controls.less ?

if(frm.domain_editor) {
frm.domain_editor.set_items_in_table();
}
frm.fields_dict.active_domains.get_data = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard pattern is to use frm.set_df_property(fieldname, 'options', options_array)

self.save()

def on_update(self):
for d in self.active_domains:
domain = frappe.get_doc('Domain', d.domain)
for d in json.loads(self.active_domains):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe we could parse Multi Check control values as list by default ?

// rename this file from _test_[name] to test_[name] to activate
// and remove above this line

QUnit.test("test: Domain Settings", function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove file

# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove file

@rmehta
Copy link
Member

rmehta commented Nov 30, 2017 via email

@nabinhait nabinhait merged commit d1aa5c6 into frappe:develop Dec 6, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants