fix: Option to pass any value for limit from client-side (#13452)

* add unlimited support to frappe.db.get_list - js

* fix: use 0 for getting all components in get_list

* fix: use autocomplete instead of select for letterheads

* fix: linting

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>

* chore: linting

* fix: add placeholder to autocomplete

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
This commit is contained in:
Mohammad Hasnain Mohsin Rajan 2021-07-05 20:03:19 +05:30 committed by GitHub
parent bb9f73b8f6
commit b5d9de1fc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 16 deletions

View file

@ -113,22 +113,20 @@ frappe.ui.form.PrintView = class {
},
).$input;
this.letterhead_selector = this.add_sidebar_item(
this.letterhead_selector_df = this.add_sidebar_item(
{
fieldtype: 'Select',
fieldtype: 'Autocomplete',
fieldname: 'letterhead',
label: __('Select Letterhead'),
options: [
this.get_default_option_for_select(__('Select Letterhead')),
__('No Letterhead')
],
placeholder: __('Select Letterhead'),
options: [__('No Letterhead')],
change: () => this.preview(),
default: this.print_settings.with_letterhead
? __('No Letterhead')
: __('Select Letterhead')
},
).$input;
);
this.letterhead_selector = this.letterhead_selector_df.$input;
this.sidebar_dynamic_section = $(
`<div class="dynamic-settings"></div>`
).appendTo(this.sidebar);
@ -336,23 +334,19 @@ frappe.ui.form.PrintView = class {
}
set_letterhead_options() {
let letterhead_options = [
this.get_default_option_for_select(__('Select Letterhead')),
__('No Letterhead')
];
let letterhead_options = [__('No Letterhead')];
let default_letterhead;
let doc_letterhead = this.frm.doc.letter_head;
return frappe.db
.get_list('Letter Head', { fields: ['name', 'is_default'] })
.get_list('Letter Head', { fields: ['name', 'is_default'], limit: 0 })
.then((letterheads) => {
this.letterhead_selector.empty();
letterheads.map((letterhead) => {
if (letterhead.is_default) default_letterhead = letterhead.name;
return letterhead_options.push(letterhead.name);
});
this.letterhead_selector.add_options(letterhead_options);
this.letterhead_selector_df.set_data(letterhead_options);
let selected_letterhead = doc_letterhead || default_letterhead;
if (selected_letterhead)
this.letterhead_selector.val(selected_letterhead);

View file

@ -10,7 +10,7 @@ frappe.db = {
if (!args.fields) {
args.fields = ['name'];
}
if (!args.limit) {
if (!('limit' in args)) {
args.limit = 20;
}
return new Promise ((resolve) => {