User page functionality merger (80%)

This commit is contained in:
Dima Malishev 2011-07-23 17:34:27 +03:00
parent 2b06ef5faa
commit 43dffa3fbe
11 changed files with 826 additions and 208 deletions

View file

@ -1,31 +1,95 @@
App.Model.DNS.loadList = function(){
App.Model.DNS.loadList = function()
{
App.Ajax.request('DNS.getList', {}, App.View.listItems);
}
App.Model.IP.loadList = function(){
App.Model.IP.loadList = function()
{
App.Ajax.request('IP.getList', {}, App.View.listItems);
}
App.Model.add = function(values, source_json) {
App.Model.USER.loadList = function()
{
App.Ajax.request('USER.getList', {}, App.View.listItems);
}
App.Model.WEB_DOMAIN.loadList = function()
{
App.Ajax.request('WEB_DOMAIN.getList', {}, App.View.listItems);
}
App.Model.MAIL.loadList = function()
{
App.Ajax.request('MAIL.getList', {}, App.View.listItems);
}
App.Model.DB.loadList = function()
{
App.Ajax.request('DB.getList', {}, App.View.listItems);
}
App.Model.CRON.loadList = function()
{
App.Ajax.request('CRON.getList', {}, App.View.listItems);
}
App.Model.add = function(values, source_json)
{
var method = App.Settings.getMethodName('add');
App.Ajax.request(method, {
spell: $.toJSON(values)
}, function(reply){
if(!reply.result) {
alert('FALSE');
App.Helpers.Warn('Changes were not applied');
}
else {
var build_method = App.Env.getWorldName() + '_entry';
var tpl = App.HTML.Build[build_method](values, 'new');
App.Ref.CONTENT..replaceWith(tpl);
// todo: reply.data;
}
});
}
App.Model.update = function(values, source_json) {
App.Model.remove = function(world, elm)
{
var method = App.Settings.getMethodName('delete');
App.Ajax.request(method,
{
spell: $('.source', elm).val()
},
function(reply)
{
if (!reply.result) {
App.Helpers.Warn('Changes were not applied');
}
else {
$(elm).remove();
}
});
}
App.Model.update = function(values, source_json, elm)
{ alert(source_json);
var method = App.Settings.getMethodName('update');
var build_method = App.Env.getWorldName() + '_entry';
App.Ajax.request(method, {
'old': source_json,
'new': App.Helpers.toJSON(values)
}, function(reply){
if(!reply.result) {
alert('FALSE');
var tpl = App.HTML.Build[build_method](App.Helpers.evalJSON(source_json));
$(elm).replaceWith(tpl);
App.Helpers.updateScreen();
App.Helpers.Warn('Changes were not applied');
}
else {
var tpl = App.HTML.Build[build_method](reply.data);
$(elm).replaceWith(tpl);
App.Helpers.updateScreen();
}
// TODO: !
});
}