From e7906001c5c97c490c5c5bfa4b8d0716bde17d91 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 2 Jan 2013 16:53:22 +0530 Subject: [PATCH 1/4] removed extended valid elements --- public/js/legacy/widgets/form/form_fields.js | 1 - 1 file changed, 1 deletion(-) diff --git a/public/js/legacy/widgets/form/form_fields.js b/public/js/legacy/widgets/form/form_fields.js index 566b891151..a219f8218c 100644 --- a/public/js/legacy/widgets/form/form_fields.js +++ b/public/js/legacy/widgets/form/form_fields.js @@ -272,7 +272,6 @@ _f.CodeField.prototype.make_input = function() { // General options theme : "advanced", plugins : "style,inlinepopups,table,advimage", - extended_valid_elements: "div[id|dir|class|align|style]", // w/h width: '100%', From 3956ed4a5d4f976c95c5aca4ece174393e7e9ca0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 2 Jan 2013 17:00:08 +0530 Subject: [PATCH 2/4] tiny_mce:removed added script|embed in extended_valid_elements --- public/js/legacy/widgets/form/form_fields.js | 1 + 1 file changed, 1 insertion(+) diff --git a/public/js/legacy/widgets/form/form_fields.js b/public/js/legacy/widgets/form/form_fields.js index a219f8218c..0ae7e88b53 100644 --- a/public/js/legacy/widgets/form/form_fields.js +++ b/public/js/legacy/widgets/form/form_fields.js @@ -272,6 +272,7 @@ _f.CodeField.prototype.make_input = function() { // General options theme : "advanced", plugins : "style,inlinepopups,table,advimage", + extended_valid_elements: "script|embed", // w/h width: '100%', From 037ae044ac34d3849f2a54442e78bc2c92f06bf4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 3 Jan 2013 12:22:16 +0530 Subject: [PATCH 3/4] listview in linked_with --- public/js/wn/form/assign_to.js | 143 ++++++++++++++++++++++++++++++ public/js/wn/form/linked_with.js | 55 ++++++------ public/js/wn/views/doclistview.js | 14 +-- public/js/wn/views/listview.js | 11 +++ 4 files changed, 186 insertions(+), 37 deletions(-) create mode 100644 public/js/wn/form/assign_to.js diff --git a/public/js/wn/form/assign_to.js b/public/js/wn/form/assign_to.js new file mode 100644 index 0000000000..7d6a2c2ebd --- /dev/null +++ b/public/js/wn/form/assign_to.js @@ -0,0 +1,143 @@ +// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com) +// +// MIT License (MIT) +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +// assign to is lined to todo +// refresh - load todos +// create - new todo +// delete to do + +wn.provide("wn.ui.form"); + +wn.ui.form.AssignTo = Class.extend({ + init: function(opts) { + $.extend(this, opts); + var me = this; + this.wrapper = $('
\ + \ +
\ +
').appendTo(this.parent); + + this.$list = this.wrapper.find(".alert-list"); + + this.wrapper.find(".btn").click(function() { + me.add(); + }); + }, + refresh: function() { + if(this.frm.doc.__islocal) { + this.parent.toggle(false); + return; + } + this.parent.toggle(true); + + var me = this; + wn.call({ + method: 'webnotes.widgets.form.assign_to.get', + args: { + doctype: me.frm.doctype, + name: me.frm.docname + }, + callback: function(r) { + me.render(r.message) + } + }) + }, + render: function(d) { + var me = this; + this.$list.empty(); + if(this.dialog) { + this.dialog.hide(); + } + + for(var i=0; i\ + %(avatar)s %(fullname)s \ + ×', d[i])) + .appendTo(this.$list); + + this.$list.find(".avatar").css("margin-top", "-7px") + this.$list.find('.avatar img').centerImage(); + } + + // set remove + this.$list.find('a.close').click(function() { + wn.call({ + method:'webnotes.widgets.form.assign_to.remove', + args: { + doctype: me.frm.doctype, + name: me.frm.docname, + assign_to: $(this).attr('data-owner') + }, + callback:function(r,rt) {me.render(r.message);} + }); + return false; + }); + }, + add: function() { + var me = this; + if(!me.dialog) { + me.dialog = new wn.ui.Dialog({ + title: 'Add to To Do', + width: 350, + fields: [ + {fieldtype:'Link', fieldname:'assign_to', options:'Profile', + label:wn._("Assign To"), + description:wn._("Add to To Do List of"), reqd:true}, + {fieldtype:'Data', fieldname:'description', label:wn._("Comment")}, + {fieldtype:'Date', fieldname:'date', label: wn._("Complete By")}, + {fieldtype:'Select', fieldname:'priority', label: wn._("Priority"), + options:'Low\nMedium\nHigh', 'default':'Medium'}, + {fieldtype:'Check', fieldname:'notify', label: wn._("Notify By Email")}, + {fieldtype:'Button', label:wn._("Add"), fieldname:'add_btn'} + ] + }); + me.dialog.fields_dict.add_btn.input.onclick = function() { + + var assign_to = me.dialog.fields_dict.assign_to.get_value(); + if(assign_to) { + wn.call({ + method:'webnotes.widgets.form.assign_to.add', + args: { + doctype: me.frm.doctype, + name: me.frm.docname, + assign_to: assign_to, + description: me.dialog.fields_dict.description.get_value(), + priority: me.dialog.fields_dict.priority.get_value(), + date: me.dialog.fields_dict.date.get_value(), + notify: me.dialog.fields_dict.notify.get_value() + }, + callback: function(r,rt) { + me.render(r.message); + } + }); + } + } + } + me.dialog.clear(); + me.dialog.show(); + } +}); + diff --git a/public/js/wn/form/linked_with.js b/public/js/wn/form/linked_with.js index aae7763945..9f3cb9cc76 100644 --- a/public/js/wn/form/linked_with.js +++ b/public/js/wn/form/linked_with.js @@ -22,7 +22,7 @@ wn.ui.form.LinkedWith = Class.extend({ }).sort(function(a, b) { return a.label > b.label ? 1 : -1 }); this.dialog = new wn.ui.Dialog({ - width: 640, + width: 700, title: wn._("Linked With"), fields: [ { fieldtype: "HTML", label: "help", @@ -60,6 +60,7 @@ wn.ui.form.LinkedWith = Class.extend({ }, make_listing: function() { var me = this; + this.listview = wn.views.get_listview(this.doctype, this); this.lst = new wn.ui.Listing({ hide_refresh: true, no_loading: true, @@ -69,34 +70,37 @@ wn.ui.form.LinkedWith = Class.extend({ parent: $(this.dialog.fields_dict.list.wrapper).empty().css("min-height", "300px") .get(0), method: 'webnotes.widgets.reportview.get', + custom_new_doc: me.listview.make_new_doc || undefined, get_args: function() { - return { - doctype: me.doctype, - fields: (!me.is_table - ? [ '`tab' + me.doctype + '`.name', - '`tab' + me.doctype + '`.modified', - '`tab' + me.doctype + '`.modified_by', - '`tab' + me.doctype + '`.docstatus'] - : [ '`tab' + me.doctype + '`.parent', - '`tab' + me.doctype + '`.parenttype', - '`tab' + me.doctype + '`.modified_by', - '`tab' + me.doctype + '`.docstatus'] - ), - filters: me.lst.filter_list.get_filters(), - docstatus: ['0','1'] + var args = { + doctype: this.doctype, + fields: this.listview.fields, + filters: this.filter_list.get_filters(), + docstatus: ['0','1'], + order_by: this.listview.order_by || undefined, + group_by: this.listview.group_by || undefined, } + return args; + + // return { + // doctype: me.doctype, + // fields: (!me.is_table + // ? [ '`tab' + me.doctype + '`.name', + // '`tab' + me.doctype + '`.modified', + // '`tab' + me.doctype + '`.modified_by', + // '`tab' + me.doctype + '`.docstatus'] + // : [ '`tab' + me.doctype + '`.parent', + // '`tab' + me.doctype + '`.parenttype', + // '`tab' + me.doctype + '`.modified_by', + // '`tab' + me.doctype + '`.docstatus'] + // ), + // filters: me.lst.filter_list.get_filters(), + // docstatus: ['0','1'] + // } }, render_row: function(parent, data) { - $(parent).html(repl('%(avatar)s \ - \ - %(doctype)s: %(name)s\ - Last Updated: %(modified)s', { - avatar: wn.avatar(data.modified_by, null, - "Last Modified By: " + wn.user_info(data.modified_by).fullname), - doctype: me.is_table ? data.parenttype : me.doctype, - modified: dateutil.comment_when(data.modified), - name: me.is_table ? data.parent : data.name - })).find('.avatar img').centerImage(); + data.doctype = this.doctype; + me.listview.render(parent, data, this); }, get_no_result_message: function() { return repl("
%(doctype)s: " + wn._("Not linked") + "
", { @@ -108,5 +112,6 @@ wn.ui.form.LinkedWith = Class.extend({ me.lst.filter_list.show_filters(true); me.lst.filter_list.clear_filters(); me.lst.set_filter(me.linked_with[me.doctype], me.frm.doc.name); + me.lst.listview = me.listview; } }); \ No newline at end of file diff --git a/public/js/wn/views/doclistview.js b/public/js/wn/views/doclistview.js index 0d9f0ebe39..1e31bc8cec 100644 --- a/public/js/wn/views/doclistview.js +++ b/public/js/wn/views/doclistview.js @@ -129,13 +129,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ } }, setup_listview: function() { - if(this.meta.__listjs) { - eval(this.meta.__listjs); - this.listview = new wn.doclistviews[this.doctype](this); - } else { - this.listview = new wn.views.ListView(this); - } - this.listview.parent = this; + this.listview = wn.views.get_listview(this.doctype, this); this.wrapper = this.$page.find('.wnlist-area'); this.page_length = 20; this.allow_delete = true; @@ -155,7 +149,6 @@ wn.views.DocListView = wn.ui.Listing.extend({ new_doctype: this.doctype, allow_delete: this.allow_delete, no_result_message: this.make_no_result(), - columns: this.listview.fields, custom_new_doc: me.listview.make_new_doc || undefined, }); @@ -188,9 +181,6 @@ wn.views.DocListView = wn.ui.Listing.extend({ }); data.doctype = this.doctype; this.listview.render(row, data, this); - }, - get_query_fields: function() { - return this.listview.fields; }, get_args: function() { var docstatus_list = this.can_submit ? $.map(this.$page.find('.show-docstatus :checked'), @@ -200,7 +190,7 @@ wn.views.DocListView = wn.ui.Listing.extend({ var args = { doctype: this.doctype, - fields: this.get_query_fields(), + fields: this.listview.fields, filters: this.filter_list.get_filters(), docstatus: docstatus_list, order_by: this.listview.order_by || undefined, diff --git a/public/js/wn/views/listview.js b/public/js/wn/views/listview.js index 5960af680b..d8341586d4 100644 --- a/public/js/wn/views/listview.js +++ b/public/js/wn/views/listview.js @@ -1,3 +1,14 @@ +wn.views.get_listview = function(doctype, parent) { + var meta = locals.DocType[doctype]; + if(meta.__listjs) { + eval(meta.__listjs); + var listview = new wn.doclistviews[doctype](parent); + } else { + var listview = new wn.views.ListView(parent); + } + return listview; +} + wn.views.ListView = Class.extend({ init: function(doclistview) { this.doclistview = doclistview; From a0212091f05ef7966c967bed7436f0b3d2856cb1 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 3 Jan 2013 12:48:24 +0530 Subject: [PATCH 4/4] merge --- public/js/wn/form/assign_to.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/public/js/wn/form/assign_to.js b/public/js/wn/form/assign_to.js index bb3b5a4c77..7d6a2c2ebd 100644 --- a/public/js/wn/form/assign_to.js +++ b/public/js/wn/form/assign_to.js @@ -32,13 +32,7 @@ wn.ui.form.AssignTo = Class.extend({ $.extend(this, opts); var me = this; this.wrapper = $('
\ -<<<<<<< HEAD \ -======= - \ ->>>>>>> eca0d233072341721da4a86ee9f6d7ce5f234f31
\
').appendTo(this.parent);