Преглед изворни кода

`add_dropdown_item` should only add unique labels (#4818)

* do not allow add_menu_button duplicate items

* JSDOC documentation
version-14
tundebabzy пре 7 година
committed by Nabin Hait
родитељ
комит
25451759fe
1 измењених фајлова са 15 додато и 0 уклоњено
  1. +15
    -0
      frappe/public/js/frappe/ui/page.js

+ 15
- 0
frappe/public/js/frappe/ui/page.js Прегледај датотеку

@@ -247,12 +247,27 @@ frappe.ui.Page = Class.extend({

//-- Generic --//

/*
* Add label to given drop down menu. If label, is already contained in the drop
* down menu, it will be ignored.
* @param {string} label - Text for the drop down menu
* @param {function} click - function to be called when `label` is clicked
* @param {Boolean} standard
* @param {object} parent - DOM object representing the parent of the drop down item lists
*/
add_dropdown_item: function(label, click, standard, parent) {
const is_already_added = () => {
let found_lists = $(parent).find('li > a.grey-link:contains(' + label + ')');
return found_lists.length > 0;
}

parent.parent().removeClass("hide");

var $li = $('<li><a class="grey-link">'+ label +'</a><li>'),
$link = $li.find("a").on("click", click);

if (is_already_added()) return;

if(standard===true) {
$li.appendTo(parent);
} else {


Loading…
Откажи
Сачувај