浏览代码

Merge pull request #4211 from rmehta/remove-filter-fix

[fix] remove filter
version-14
Rushabh Mehta 7 年前
committed by GitHub
父节点
当前提交
09dcc1a8cb
共有 2 个文件被更改,包括 28 次插入5 次删除
  1. +23
    -5
      frappe/public/js/frappe/ui/filters/filters.js
  2. +5
    -0
      socketio.js

+ 23
- 5
frappe/public/js/frappe/ui/filters/filters.js 查看文件

@@ -57,6 +57,8 @@ frappe.ui.FilterList = Class.extend({
}, },


add_filter: function(doctype, fieldname, condition, value, hidden) { add_filter: function(doctype, fieldname, condition, value, hidden) {
// adds a new filter, returns true if filter has been added

// allow equal to be used as like // allow equal to be used as like
let base_filter = this.base_list.page.fields_dict[fieldname]; let base_filter = this.base_list.page.fields_dict[fieldname];
if (base_filter if (base_filter
@@ -64,7 +66,8 @@ frappe.ui.FilterList = Class.extend({
|| (condition==='=' && base_filter.df.condition==='like'))) { || (condition==='=' && base_filter.df.condition==='like'))) {
// if filter exists in base_list, then exit // if filter exists in base_list, then exit
this.base_list.page.fields_dict[fieldname].set_input(value); this.base_list.page.fields_dict[fieldname].set_input(value);
return;

return true;
} }


if(doctype && fieldname if(doctype && fieldname
@@ -75,7 +78,7 @@ frappe.ui.FilterList = Class.extend({
title: 'Invalid Filter', title: 'Invalid Filter',
indicator: 'red' indicator: 'red'
}); });
return;
return false;
} }


this.wrapper.find('.show_filters').toggle(true); this.wrapper.find('.show_filters').toggle(true);
@@ -83,7 +86,7 @@ frappe.ui.FilterList = Class.extend({


if (is_new_filter && this.wrapper.find(".is-new-filter:visible").length) { if (is_new_filter && this.wrapper.find(".is-new-filter:visible").length) {
// only allow 1 new filter at a time! // only allow 1 new filter at a time!
return;
return false;
} }


var filter = this.push_new_filter(doctype, fieldname, condition, value); var filter = this.push_new_filter(doctype, fieldname, condition, value);
@@ -103,7 +106,7 @@ frappe.ui.FilterList = Class.extend({
filter.$btn_group.addClass("hide"); filter.$btn_group.addClass("hide");
} }


return filter;
return true;
}, },
push_new_filter: function(doctype, fieldname, condition, value) { push_new_filter: function(doctype, fieldname, condition, value) {
if(this.filter_exists(doctype, fieldname, condition, value)) { if(this.filter_exists(doctype, fieldname, condition, value)) {
@@ -128,6 +131,19 @@ frappe.ui.FilterList = Class.extend({
return filter; return filter;
}, },


remove: function(filter) {
// remove `filter` from flist
for (var i in this.filters) {
if (this.filters[i] === filter) {
break;
}
}
if (i!==undefined) {
// remove index
this.splice(i, 1);
}
},

filter_exists: function(doctype, fieldname, condition, value) { filter_exists: function(doctype, fieldname, condition, value) {
var flag = false; var flag = false;
for(var i in this.filters) { for(var i in this.filters) {
@@ -261,9 +277,11 @@ frappe.ui.Filter = Class.extend({


apply: function() { apply: function() {
var f = this.get_value(); var f = this.get_value();
this.flist.filters.pop();

this.flist.remove(this);
this.flist.push_new_filter(f[0], f[1], f[2], f[3]); this.flist.push_new_filter(f[0], f[1], f[2], f[3]);
this.wrapper.remove(); this.wrapper.remove();
this.flist.update_filters();
}, },


remove: function(dont_run) { remove: function(dont_run) {


+ 5
- 0
socketio.js 查看文件

@@ -38,6 +38,11 @@ io.on('connection', function(socket) {
} }


// console.log("connection!"); // console.log("connection!");
if (!socket.request.headers.cookie) {
return;
}


var sid = cookie.parse(socket.request.headers.cookie).sid var sid = cookie.parse(socket.request.headers.cookie).sid
if(!sid) { if(!sid) {
return; return;


正在加载...
取消
保存