@@ -30,7 +30,6 @@ var user_fullname=null; | |||
var user_email=null; | |||
var user_img = {}; | |||
var home_page=null; | |||
var hide_autosuggest=null; | |||
var page_body=null; | |||
var pscript = {}; | |||
@@ -61,5 +60,4 @@ var cur_frm=null; | |||
var pscript = {}; | |||
var validated = true; | |||
var validation_message = ''; | |||
var tinymce_loaded = null; | |||
var cur_autosug = null; | |||
var tinymce_loaded = null; |
@@ -90,7 +90,7 @@ _e.make = function() { | |||
} | |||
d.onhide = function() { | |||
hide_autosuggest(); | |||
} | |||
d.make_body([ | |||
@@ -107,57 +107,53 @@ _e.make = function() { | |||
$td(d.rows['Format'].tab,0,1).cur_sel = d.widgets['Format']; | |||
// ---- add auto suggest ---- | |||
var opts = { script: '', json: true, maxresults: 10 }; | |||
wn.require('lib/js/legacy/widgets/autosuggest.js'); | |||
function split( val ) { | |||
return val.split( /,\s*/ ); | |||
} | |||
function extractLast( term ) { | |||
return split(term).pop(); | |||
} | |||
var as = new AutoSuggest(d.widgets['To'], opts); | |||
as.custom_select = function(txt, sel) { | |||
// ---- add to the last comma ---- | |||
var r = ''; | |||
var tl = txt.split(','); | |||
for(var i=0;i<tl.length-1;i++) r=r+tl[i]+','; | |||
r = r+(r?' ':'')+sel; | |||
if(r[r.length-1]==NEWLINE) r=substr(0,r.length-1); | |||
return r; | |||
} | |||
var emailto = d.widgets['To'] | |||
as.set_input_value = function(new_txt) { | |||
if(emailto.value && emailto.value.indexOf(',')!=-1) { | |||
var txt = emailto.value.split(','); | |||
txt.splice(txt.length - 1, 1, new_txt); | |||
for(var i=0;i<txt.length-1;i++) txt[i] = strip(txt[i]); | |||
emailto.value = txt.join(', '); | |||
} else { | |||
emailto.value = new_txt; | |||
} | |||
} | |||
// ---- override server call ---- | |||
as.doAjaxRequest = function(txt) { | |||
var pointer = as; var q = ''; | |||
// ---- get last few letters typed ---- | |||
var last_txt = txt.split(','); | |||
last_txt = last_txt[last_txt.length-1]; | |||
// ---- show options ---- | |||
var call_back = function(r,rt) { | |||
as.aSug = []; | |||
if(!r.cl) return; | |||
for (var i=0;i<r.cl.length;i++) { | |||
as.aSug.push({'id':r.cl[i], 'value':r.cl[i], 'info':''}); | |||
} | |||
as.createList(as.aSug); | |||
} | |||
$c('webnotes.utils.email_lib.get_contact_list',{'select':_e.email_as_field, 'from':_e.email_as_dt, 'where':_e.email_as_in, 'txt':(last_txt ? strip(last_txt) : '%')},call_back); | |||
return; | |||
} | |||
var sel; | |||
$(d.widgets['To']) | |||
.bind( "keydown", function(event) { | |||
if (event.keyCode === $.ui.keyCode.TAB && | |||
$(this).data( "autocomplete" ).menu.active ) { | |||
event.preventDefault(); | |||
} | |||
}) | |||
.autocomplete({ | |||
source: function(request, response) { | |||
wn.call({ | |||
method:'webnotes.utils.email_lib.get_contact_list', | |||
args: { | |||
'select': _e.email_as_field, | |||
'from': _e.email_as_dt, | |||
'where': _e.email_as_in, | |||
'txt': extractLast(request.term).value || '%' | |||
}, | |||
callback: function(r) { | |||
response($.ui.autocomplete.filter( | |||
r.cl || [], extractLast(request.term))); | |||
} | |||
}); | |||
}, | |||
focus: function() { | |||
// prevent value inserted on focus | |||
return false; | |||
}, | |||
select: function( event, ui ) { | |||
var terms = split( this.value ); | |||
// remove the current input | |||
terms.pop(); | |||
// add the selected item | |||
terms.push( ui.item.value ); | |||
// add placeholder to get the comma-and-space at the end | |||
terms.push( "" ); | |||
this.value = terms.join( ", " ); | |||
return false; | |||
} | |||
}); | |||
_e.dialog = d; | |||
} | |||
@@ -703,6 +703,7 @@ LinkField.prototype.set_input_value = function(val) { | |||
// not in form, do nothing | |||
if(me.not_in_form) { | |||
$(this.txt).val(val); | |||
return; | |||
} | |||
@@ -477,8 +477,6 @@ _f.Frm.prototype.refresh_print_layout = function() { | |||
_f.Frm.prototype.hide = function() { | |||
$dh(this.wrapper); | |||
this.display = 0; | |||
if(hide_autosuggest) | |||
hide_autosuggest(); | |||
} | |||
// -------------------------------------------------------------------------------------- | |||
@@ -268,7 +268,7 @@ $(document).bind('click', function(e) { | |||
if(_f.cur_grid_cell && !is_target_input() && !is_target_toolbar()) { | |||
if(!(text_dialog && text_dialog.display) | |||
&& !datepicker_active && !(selector && selector.display) && !(cur_autosug)) { | |||
&& !datepicker_active && !(selector && selector.display)) { | |||
_f.cur_grid_cell.grid.cell_deselect(); | |||
} | |||
} | |||
@@ -57,8 +57,6 @@ TabbedPage.prototype.add_tab = function(n, onshow, no_body, with_heading) { | |||
tab.collapse = function() { | |||
if(this.tab_body)$dh(this.tab_body); this.className = ''; | |||
if(hide_autosuggest) | |||
hide_autosuggest(); | |||
} | |||
tab.set_selected = function() { | |||
if(me.cur_tab) me.cur_tab.collapse(); | |||
@@ -176,9 +176,6 @@ wn.widgets.Dialog = function(opts) { | |||
unfreeze(); | |||
$dh(this.wrapper); | |||
// clear open autosuggests | |||
if(cur_autosug) cur_autosug.clearSuggestions(); | |||
// flags | |||
this.display = false; | |||
cur_dialog = null; | |||
@@ -283,10 +283,17 @@ wn.ui.Listing = Class.extend({ | |||
}, | |||
render_grid: function() { | |||
//this.gridid = wn.dom.set_unique_id() | |||
if(this.columns[0].field!='_idx') { | |||
this.columns = [{field:'_idx', name: 'Sr.', width: 40}].concat(this.columns); | |||
} | |||
$.each(this.columns, function(i, c) { | |||
if(!c.id) c.id = c.field; | |||
}) | |||
// add sr in data | |||
$.each(this.data, function(i, v) { | |||
v._idx = i+1; | |||
}) | |||
wn.require('lib/js/lib/slickgrid/slick.grid.css'); | |||
wn.require('lib/js/lib/slickgrid/slick-default-theme.css'); | |||
@@ -1,84 +0,0 @@ | |||
[ | |||
{ | |||
'creation': '2011-02-12 10:07:59', | |||
'disabled': 'No', | |||
'docstatus': 0, | |||
'doctype': 'Module Def', | |||
'doctype_list': None, | |||
'file_list': None, | |||
'idx': None, | |||
'is_hidden': 'Yes', | |||
'last_updated_date': None, | |||
'modified': '2011-02-12 10:07:59', | |||
'modified_by': 'Administrator', | |||
'module_desc': None, | |||
'module_icon': None, | |||
'module_label': 'Core', | |||
'module_name': 'Core', | |||
'module_page': None, | |||
'module_seq': None, | |||
'name': 'Core', | |||
'owner': 'Administrator', | |||
'parent': None, | |||
'parentfield': None, | |||
'parenttype': None, | |||
'trash_reason': None, | |||
'widget_code': None | |||
}, | |||
{ | |||
'click_function': None, | |||
'creation': '2011-02-12 10:07:59', | |||
'description': None, | |||
'display_name': None, | |||
'doc_name': 'Pages', | |||
'doc_type': 'Separator', | |||
'docstatus': 0, | |||
'doctype': 'Module Def Item', | |||
'fields': None, | |||
'hide': None, | |||
'icon': None, | |||
'idx': None, | |||
'modified': '2011-02-12 10:07:59', | |||
'modified_by': 'Administrator', | |||
'name': 'MDI00288', | |||
'owner': 'Administrator', | |||
'parent': 'Core', | |||
'parentfield': 'items', | |||
'parenttype': 'Module Def' | |||
}, | |||
{ | |||
'click_function': None, | |||
'creation': '2011-02-12 10:07:59', | |||
'description': None, | |||
'display_name': 'Manage Users', | |||
'doc_name': 'Manage Users', | |||
'doc_type': 'Pages', | |||
'docstatus': 0, | |||
'doctype': 'Module Def Item', | |||
'fields': None, | |||
'hide': None, | |||
'icon': None, | |||
'idx': None, | |||
'modified': '2011-02-12 10:07:59', | |||
'modified_by': 'Administrator', | |||
'name': 'MDI00289', | |||
'owner': 'Administrator', | |||
'parent': 'Core', | |||
'parentfield': 'items', | |||
'parenttype': 'Module Def' | |||
}, | |||
{ | |||
'creation': '2011-02-12 10:07:59', | |||
'docstatus': 0, | |||
'doctype': 'Module Def Role', | |||
'idx': 1, | |||
'modified': '2011-02-12 10:07:59', | |||
'modified_by': 'Administrator', | |||
'name': 'MDR00076', | |||
'owner': 'Administrator', | |||
'parent': 'Core', | |||
'parentfield': 'roles', | |||
'parenttype': 'Module Def', | |||
'role': 'Administrator' | |||
} | |||
] |
@@ -1,27 +0,0 @@ | |||
# Role, Administrator | |||
[ | |||
# These values are common in all dictionaries | |||
{ | |||
'creation': '2010-08-08 17:08:51', | |||
'docstatus': 0, | |||
'modified': '2009-03-12 12:01:57', | |||
'modified_by': 'Administrator', | |||
'owner': 'Administrator' | |||
}, | |||
# These values are common for all Role | |||
{ | |||
'doctype': 'Role', | |||
'idx': 0, | |||
'module': 'Core', | |||
'name': '__common__', | |||
'role_name': 'Administrator' | |||
}, | |||
# Role, Administrator | |||
{ | |||
'doctype': 'Role', | |||
'name': 'Administrator' | |||
} | |||
] |
@@ -1,26 +0,0 @@ | |||
# Role, All | |||
[ | |||
# These values are common in all dictionaries | |||
{ | |||
'creation': '2010-08-08 17:08:51', | |||
'docstatus': 0, | |||
'modified': '2009-03-12 14:40:07', | |||
'modified_by': 'Administrator', | |||
'owner': 'Administrator' | |||
}, | |||
# These values are common for all Role | |||
{ | |||
'doctype': 'Role', | |||
'module': 'Core', | |||
'name': '__common__', | |||
'role_name': 'All' | |||
}, | |||
# Role, All | |||
{ | |||
'doctype': 'Role', | |||
'name': 'All' | |||
} | |||
] |
@@ -1,50 +0,0 @@ | |||
# Role, Guest | |||
[ | |||
# These values are common in all dictionaries | |||
{ | |||
'creation': '2010-08-08 17:08:51', | |||
'docstatus': 0, | |||
'modified': '2010-01-13 16:45:40', | |||
'modified_by': 'Administrator', | |||
'owner': 'Administrator' | |||
}, | |||
# These values are common for all DefaultValue | |||
{ | |||
'defvalue': '1', | |||
'doctype': 'DefaultValue', | |||
'name': '__common__', | |||
'parent': 'Guest', | |||
'parentfield': 'defaults', | |||
'parenttype': 'Role' | |||
}, | |||
# These values are common for all Role | |||
{ | |||
'doctype': 'Role', | |||
'module': 'Core', | |||
'name': '__common__', | |||
'role_name': 'Guest' | |||
}, | |||
# Role, Guest | |||
{ | |||
'doctype': 'Role', | |||
'name': 'Guest' | |||
}, | |||
# DefaultValue | |||
{ | |||
'defkey': 'hide_webnotes_toolbar', | |||
'doctype': 'DefaultValue', | |||
'idx': 1 | |||
}, | |||
# DefaultValue | |||
{ | |||
'defkey': 'hide_sidebars', | |||
'doctype': 'DefaultValue', | |||
'idx': 2 | |||
} | |||
] |
@@ -20,56 +20,9 @@ | |||
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |||
# | |||
class BaseModel: | |||
""" | |||
New style models will be inherited from this base model class | |||
This will contain methods for save update | |||
Standard attributes: | |||
_type | |||
_id | |||
_created_by | |||
_created_on | |||
_modified_by | |||
_modified_on | |||
""" | |||
def __init__(self, model_type = None, model_id = None, attributes = {}): | |||
self._type = model_type | |||
self._id = model_id | |||
if attributes: | |||
self.__dict__.update(attributes) | |||
def __getattr__(self, name): | |||
""" | |||
Getter is overridden so that it does not throw an exception | |||
""" | |||
if name in self.__dict__: | |||
return self.__dict__[name] | |||
else: | |||
return None | |||
def _read(self): | |||
""" | |||
Read | |||
""" | |||
self.__dict__.update(webnotes.conn.sql(""" | |||
select * from `%s` where _id=%s | |||
""", (self._type, self._id), as_dict=1)[0]) | |||
def _create(self): | |||
""" | |||
Create | |||
""" | |||
pass | |||
def _update(self): | |||
""" | |||
Update | |||
""" | |||
pass | |||
def _delete(self): | |||
""" | |||
Delete | |||
""" | |||
pass | |||
install_docs = [ | |||
{'doctype':'Module Def', 'name': 'Core'}, | |||
{'doctype':'Role', 'name': 'Administrator'}, | |||
{'doctype':'Role', 'name': 'All'}, | |||
{'doctype':'Role', 'name': 'Guest'} | |||
] |