mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Cfg: Add create / edit screen
This commit is contained in:
parent
7f31d49848
commit
40ee795c29
@ -17,16 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*;
|
||||
import gplx.xowa.specials.*; import gplx.xowa.htmls.bridges.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.lists.*;
|
||||
import gplx.xowa.addons.apps.cfgs.specials.lists.*; import gplx.xowa.addons.apps.cfgs.specials.items.*;
|
||||
public class Xoa_cfg_addon implements Xoax_addon_itm, Xoax_addon_itm__special, Xoax_addon_itm__json {
|
||||
public Xow_special_page[] Special_pages() {
|
||||
return new Xow_special_page[]
|
||||
{ Xocfg_list_special.Prototype
|
||||
, Xocfg_item_special.Prototype
|
||||
};
|
||||
}
|
||||
public Bridge_cmd_itm[] Json_cmds() {
|
||||
return new Bridge_cmd_itm[]
|
||||
{
|
||||
{ Xocfg_item_bridge.Prototype
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class Xoitm_meta_tbl implements Db_tbl {
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name;
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Upsert(int itm_id, int scope_id, int gui_type, String gui_args, String itm_key, String itm_dflt) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_id), itm_id, scope_id, gui_type, gui_args, itm_key, itm_dflt);
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_id), itm_id, itm_key, scope_id, gui_type, gui_args, itm_dflt);
|
||||
}
|
||||
public Xoitm_meta_itm Select_by_key_or_null(String key) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__itm_key).Exec_select__rls_auto();
|
||||
|
@ -42,7 +42,9 @@ public class Xogui_grp implements Xogui_nde, Mustache_doc_itm {
|
||||
public void Itms__add(Xogui_itm itm) {
|
||||
}
|
||||
public boolean Mustache__write(String key, Mustache_bfr bfr) {
|
||||
return true;
|
||||
if (String_.Eq(key, "id")) bfr.Add_int(id);
|
||||
else if (String_.Eq(key, "key")) bfr.Add_str_u8(key);
|
||||
return false;
|
||||
}
|
||||
public Mustache_doc_itm[] Mustache__subs(String key) {
|
||||
return Mustache_doc_itm_.Ary__empty;
|
||||
|
@ -170,4 +170,8 @@ public class Xogui_mgr {
|
||||
cur_regy.Deleted__commit();
|
||||
}
|
||||
}
|
||||
public static Xogui_mgr New(Xoa_app app) {
|
||||
Xocfg_db_mgr db_mgr = new Xocfg_db_mgr(app.User().User_db_mgr().Conn());
|
||||
return new Xogui_mgr(db_mgr);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.specials.items; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*;
|
||||
import gplx.dbs.sys.*;
|
||||
import gplx.langs.jsons.*;
|
||||
public class Xocfg_item_bridge implements gplx.xowa.htmls.bridges.Bridge_cmd_itm {
|
||||
private Xoa_app app;
|
||||
public void Init_by_app(Xoa_app app) {
|
||||
this.app = app;
|
||||
}
|
||||
public String Exec(Json_nde data) {
|
||||
byte proc_id = proc_hash.Get_as_byte_or(data.Get_as_bry_or(Msg__proc, null), Byte_ascii.Max_7_bit);
|
||||
Json_nde args = data.Get_kv(Msg__args).Val_as_nde();
|
||||
switch (proc_id) {
|
||||
case Proc__upsert: Save(args); break;
|
||||
default: throw Err_.new_unhandled_default(proc_id);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private void Save(Json_nde args) {
|
||||
String data = args.Get_as_str("data");
|
||||
gplx.xowa.addons.apps.cfgs.dbs.Xocfg_itm_bldr itm_bldr = new gplx.xowa.addons.apps.cfgs.dbs.Xocfg_itm_bldr(new gplx.xowa.addons.apps.cfgs.dbs.Xocfg_db_mgr(app.User().User_db_mgr().Conn()));
|
||||
String[] ary = String_.Split(data, "|");
|
||||
if (String_.Eq(ary[0], "grp")) {
|
||||
itm_bldr.Create_grp(ary[1], ary[2], ary[3], ary[4]);
|
||||
}
|
||||
else {
|
||||
itm_bldr.Create_itm(ary[1], ary[2], ary[3], ary[4], ary[5], ary[6], ary[7], ary[8]);
|
||||
}
|
||||
}
|
||||
|
||||
private static final byte[] Msg__proc = Bry_.new_a7("proc"), Msg__args = Bry_.new_a7("args");
|
||||
private static final byte Proc__upsert = 0;
|
||||
private static final Hash_adp_bry proc_hash = Hash_adp_bry.cs()
|
||||
.Add_str_byte("upsert" , Proc__upsert)
|
||||
;
|
||||
|
||||
public byte[] Key() {return BRIDGE_KEY;} public static final byte[] BRIDGE_KEY = Bry_.new_a7("cfg.item.exec");
|
||||
public static final Xocfg_item_bridge Prototype = new Xocfg_item_bridge(); Xocfg_item_bridge() {}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.specials.items; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*;
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
import gplx.xowa.addons.apps.cfgs.gui.*;
|
||||
class Xocfg_item_html extends Xow_special_wtr__base {
|
||||
public Xocfg_item_html() {}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "app", "cfg", "item");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xocfg_item.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return new Xogui_grp(0, 1, "test");
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
Xopg_tag_wtr_.Add__xocss (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xohelp (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xolog (head_tags, app.Fsys_mgr().Http_root());
|
||||
Xopg_tag_wtr_.Add__xoajax (head_tags, app.Fsys_mgr().Http_root(), app);
|
||||
|
||||
head_tags.Add(Xopg_tag_itm.New_css_file(addon_dir.GenSubFil_nest("bin", "xocfg_item.css")));
|
||||
head_tags.Add(Xopg_tag_itm.New_js_file(addon_dir.GenSubFil_nest("bin", "xocfg_item.js")));
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.addons.apps.cfgs.specials.items; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*; import gplx.xowa.addons.apps.cfgs.specials.*;
|
||||
import gplx.xowa.specials.*; import gplx.core.net.qargs.*;
|
||||
public class Xocfg_item_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
new Xocfg_item_html().Bld_page_by_mustache(wiki.App(), page, this);
|
||||
}
|
||||
Xocfg_item_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
public Xow_special_page Special__clone() {return this;}
|
||||
public static final Xow_special_page Prototype = new Xocfg_item_special(Xow_special_meta.New_xo("XowaCfgItem", "Option Admin"));
|
||||
}
|
@ -19,10 +19,17 @@ package gplx.xowa.addons.apps.cfgs.specials.lists; import gplx.*; import gplx.xo
|
||||
import gplx.xowa.specials.*; import gplx.langs.mustaches.*; import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.pages.tags.*;
|
||||
import gplx.xowa.addons.apps.cfgs.gui.*;
|
||||
class Xocfg_list_html extends Xow_special_wtr__base {
|
||||
private final String grp_key, ctx, lang;
|
||||
public Xocfg_list_html(String grp_key, String ctx, String lang) {
|
||||
this.grp_key = grp_key;
|
||||
this.ctx = ctx;
|
||||
this.lang = lang;
|
||||
}
|
||||
@Override protected Io_url Get_addon_dir(Xoa_app app) {return app.Fsys_mgr().Http_root().GenSubDir_nest("bin", "any", "xowa", "addon", "app", "cfg", "list");}
|
||||
@Override protected Io_url Get_mustache_fil(Io_url addon_dir) {return addon_dir.GenSubFil_nest("bin", "xocfg_list.mustache.html");}
|
||||
@Override protected Mustache_doc_itm Bld_mustache_root(Xoa_app app) {
|
||||
return new Xogui_grp(0, 0, "test");
|
||||
Xogui_mgr mgr = Xogui_mgr.New(app);
|
||||
return mgr.Get_by_grp(grp_key, ctx, lang);
|
||||
}
|
||||
@Override protected void Bld_tags(Xoa_app app, Io_url addon_dir, Xopage_html_data page_data) {
|
||||
Xopg_tag_mgr head_tags = page_data.Head_tags();
|
||||
|
@ -19,7 +19,13 @@ package gplx.xowa.addons.apps.cfgs.specials.lists; import gplx.*; import gplx.xo
|
||||
import gplx.xowa.specials.*; import gplx.core.net.qargs.*;
|
||||
public class Xocfg_list_special implements Xow_special_page {
|
||||
public void Special__gen(Xow_wiki wiki, Xoa_page page, Xoa_url url, Xoa_ttl ttl) {
|
||||
new Xocfg_list_html().Bld_page_by_mustache(wiki.App(), page, this);
|
||||
Gfo_qarg_mgr url_args = new Gfo_qarg_mgr().Init(url.Qargs_ary());
|
||||
|
||||
String grp = url_args.Read_str_or("grp", "");
|
||||
String ctx = url_args.Read_str_or("ctx", "app");
|
||||
String lang = url_args.Read_str_or("lang", wiki.App().User().Wikii().Lang().Key_str());
|
||||
|
||||
new Xocfg_list_html(grp, ctx, lang).Bld_page_by_mustache(wiki.App(), page, this);
|
||||
}
|
||||
Xocfg_list_special(Xow_special_meta special__meta) {this.special__meta = special__meta;}
|
||||
public Xow_special_meta Special__meta() {return special__meta;} private final Xow_special_meta special__meta;
|
||||
|
Loading…
Reference in New Issue
Block a user