소스 검색

`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 {


불러오는 중...
취소
저장