sencha touch check login before every method -
in sencha touch, need check user login before every action in controller. config "method" not good, because requires action called route. use call action function this.fireevent().
updated:
i want call checklogin() before onnewnotecommand(), onsavenotecommand(), ondeletenotecommand(), don't want place checklogin() inside these function because have call checklogin() many other functions. how can it? thank you.
ext.define('note.controller.note',{ extend:'note.controller.basecontroller', config:{ refs:{ notelistcontainer:'noteslistcontainer', noteeditor:'noteeditor' }, control:{ noteslistcontainer:{ newnotecommand:'onnewnotecommand', editnotecommand:'oneditnotecommand', onnodelistdisclose:'oneditnotecommand' }, noteeditor:{ savenotecommand:'onsavenotecommand', deletenotecommand:'ondeletenotecommand', homecommand:'onhomecommand' } } }, checklogin:function(){ console.log('checklogin function'); }, loghomecommand:function(action){ console.log('loghomecommand'); action.resume(); }, ondeletenotecommand:function(){ var noteeditor = this.getnoteeditor(); var currentnote = noteeditor.getrecord(); notesstore = ext.getstore('notes'); notesstore.remove(currentnote); notesstore.sync(); this.activenoteslist(); }, onsavenotecommand:function(){ console.log('onsavenotecommand'); var noteeditor = this.getnoteeditor(); var currentnote = noteeditor.getrecord(); var newvalues= noteeditor.getvalues(); currentnote.set('title',newvalues.title); currentnote.set('narrative',newvalues.narrative); var errors = currentnote.validate(); console.log(errors); if(! errors.isvalid()){ ext.msg.alert('wait!','please check error'); currentnote.reject(); return; } notesstore = ext.getstore('notes'); if( null == notesstore.findrecord('id',currentnote.data.id)){ notesstore.add(currentnote); } notesstore.sync(); this.activenoteslist(); }, activenoteslist:function(){ ext.viewport.animateactiveitem(this.getnotelistcontainer(),{ type:'slide', direction:'right' }); }, activenoteeditor:function(model){ var noteeditor = this.getnoteeditor(); console.log(noteeditor); noteeditor.setrecord(model); ext.viewport.animateactiveitem(noteeditor,{ type:'slide', direction:'left' }); }, onnewnotecommand:function(){ console.log('onnewnotecommand'); var = new date(); var noteid = (now.gettime()).tostring() + (this.getrandomint(0,100)).tostring(); var notemodel = ext.create('note.model.note',{ id:noteid, datecreated:now, title:'', narrative:'' }); this.activenoteeditor(notemodel); }, getrandomint: function (min, max) { return math.floor(math.random() * (max - min + 1)) + min; }, oneditnotecommand:function(list,record){ console.log('oneditnotecommand'); this.activenoteeditor(record); }, launch:function(){ this.callparent(arguments); console.log('launch'); }, init:function(){ this.callparent(arguments); console.log('init'); }
})
Comments
Post a Comment