tag tool done
This commit is contained in:
parent
7813bb008e
commit
94f36dc97c
@ -1,2 +1,20 @@
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1300, 42, 0, 0, 'saimod_mojotrollz_db_tags', 'action', NULL);
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (1310, 42, 2, 1300, 'list', 'table', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5400, 42, 0, 0, 'saimod_mojotrollz_db_tags', 'action', NULL);
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5410, 42, 2, 5400, 'type_list', 'table', 'INT');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5430, 42, 2, 5400, 'type_del', 'table', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5431, 42, 2, 5400, 'type_del', 'id', 'INT');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5440, 42, 2, 5400, 'type_add', 'table', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5441, 42, 2, 5400, 'type_add', 'id', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5442, 42, 2, 5400, 'type_add', 'name', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5443, 42, 2, 5400, 'type_add', 'description', 'STRING');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5420, 42, 2, 5400, 'value_list', 'type', 'INT');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5450, 42, 2, 5400, 'value_del', 'type', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5451, 42, 2, 5400, 'value_del', 'id', 'INT');
|
||||
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5460, 42, 2, 5400, 'value_add', 'type', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5461, 42, 2, 5400, 'value_add', 'id', 'INT');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5462, 42, 2, 5400, 'value_add', 'value', 'STRING');
|
||||
INSERT INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (5463, 42, 2, 5400, 'value_add', 'description', 'STRING');
|
||||
@ -9,11 +9,13 @@ function init_saimod_mojotrollz_db_tags(){
|
||||
}
|
||||
|
||||
function load_tags_tab(table){
|
||||
$('#tab_content').load(SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_tags&action=list&table='+table, function(){
|
||||
register_type_editadd();
|
||||
$('#tab_content').load(SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_tags&action=type_list&table='+table, function(){
|
||||
register_type_add();
|
||||
register_type_edit();
|
||||
register_type_del();
|
||||
register_type_values();
|
||||
$('.btn_type_values').click(function(){
|
||||
load_value_tab($(this).attr('_type'));
|
||||
});
|
||||
$('img#loader').hide();});
|
||||
}
|
||||
|
||||
@ -64,9 +66,57 @@ function register_type_del(){
|
||||
});
|
||||
}
|
||||
|
||||
function register_type_values(){
|
||||
$('.btn_type_values').click(function(){
|
||||
$('#tab_content').load(SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_tags&action=value_list&id='+$(this).attr('_id')+'&table='+$(this).attr('_table'), function(){
|
||||
$('img#loader').hide();});
|
||||
function load_value_tab(type){
|
||||
$('#tab_content').load(SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_tags&action=value_list&type='+type, function(){
|
||||
register_value_add();
|
||||
register_value_edit();
|
||||
register_value_del();
|
||||
$('img#loader').hide();});
|
||||
}
|
||||
|
||||
function register_value_add(){
|
||||
$('#btn_value_add').click(function(){
|
||||
_type = $(this).attr('_type');
|
||||
$.ajax({ type :'GET',
|
||||
url : SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_tags&action=value_add'+
|
||||
'&id='+$('#input_value_id').val()+
|
||||
'&type='+_type+
|
||||
'&value='+$('#input_value_value').val()+
|
||||
'&description='+$('#input_value_description').val(),
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
load_value_tab(_type);
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function register_value_edit(){
|
||||
$('.btn_value_edit').click(function(){
|
||||
$('#input_value_id').val($(this).attr('_id'));
|
||||
$('#input_value_value').val($(this).attr('_value'));
|
||||
$('#input_value_description').val($(this).attr('_description'));
|
||||
});
|
||||
}
|
||||
|
||||
function register_value_del(){
|
||||
$('.btn_value_del').click(function(){
|
||||
if (confirm('Are you sure you want to delete?')) {
|
||||
_id = $(this).attr('_id');
|
||||
_type = $(this).attr('_type');
|
||||
$.ajax({ type :'GET',
|
||||
url : SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_db_tags&action=value_del'+
|
||||
'&id='+_id+
|
||||
'&type='+_type,
|
||||
success : function(data) {
|
||||
if(data.status){
|
||||
load_value_tab(_type);
|
||||
}else{
|
||||
alert('Problem: '+data);}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class DB_TAGS_TYPE_DEL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
'',
|
||||
'DELETE FROM mojotrollz_tags_type WHERE `table` = ? AND `id` = ?;'
|
||||
);}}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class DB_TAGS_TYPE_INSERTUPDATE extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
'',
|
||||
'INSERT INTO `mojotrollz_tags_type` (`id`, `table`, `name`, `description`)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE `name`=VALUES(`name`), `description`=VALUES(`description`);'
|
||||
);}}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class DB_TAGS_VALUE_DEL extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
'',
|
||||
'DELETE FROM mojotrollz_tags_value WHERE `type` = ? AND `id` = ?;'
|
||||
);}}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class DB_TAGS_VALUE_INSERTUPDATE extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
'',
|
||||
'INSERT INTO `mojotrollz_tags_value` (`id`, `type`, `value`, `description`)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE `value`=VALUES(`value`), `description`=VALUES(`description`);'
|
||||
);}}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace DBD;
|
||||
|
||||
class DB_TAGS_VALUE_LIST extends \SYSTEM\DB\QP {
|
||||
protected static function query(){
|
||||
return new \SYSTEM\DB\QQuery(get_class(),
|
||||
'',
|
||||
'SELECT * FROM mojotrollz_tags_value WHERE type = ?;'
|
||||
);}}
|
||||
|
||||
@ -1,13 +1,40 @@
|
||||
<?php
|
||||
class saimod_mojotrollz_db_tags extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_list($table){
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_type_list($table){
|
||||
$elements = '';
|
||||
$res = \DBD\DB_TAGS_TYPE_LIST::QQ(array($table));
|
||||
while($row = $res->next()){
|
||||
$elements .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_tags/tpl/type_list_element.tpl'),$row);}
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_tags/tpl/type_list.tpl'),array('table' => $table, 'elements' => $elements));}
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_value_add($type,$id,$value,$description){
|
||||
if(!\DBD\DB_TAGS_VALUE_INSERTUPDATE::QI(array($id,$type,$value,$description))){
|
||||
throw new ERROR("Could not insert Value.");}
|
||||
return JsonResult::ok();}
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_value_del($type,$id){
|
||||
if(!\DBD\DB_TAGS_VALUE_DEL::QI(array($type,$id))){
|
||||
throw new ERROR("Could not delete Value.");}
|
||||
return JsonResult::ok();}
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_type_add($table,$id,$name,$description){
|
||||
if(!\DBD\DB_TAGS_TYPE_INSERTUPDATE::QI(array($id,$table,$name,$description))){
|
||||
throw new ERROR("Could not insert Type.");}
|
||||
return JsonResult::ok();}
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_type_del($table,$id){
|
||||
if(!\DBD\DB_TAGS_TYPE_DEL::QI(array($table,$id))){
|
||||
throw new ERROR("Could not delete Type.");}
|
||||
return JsonResult::ok();}
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags_action_value_list($type){
|
||||
$elements = '';
|
||||
$res = \DBD\DB_TAGS_VALUE_LIST::QQ(array($type));
|
||||
while($row = $res->next()){
|
||||
$elements .= \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_tags/tpl/value_list_element.tpl'),$row);}
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\SERVERPATH(new PSAI(),'saimod_mojotrollz_db_tags/tpl/value_list.tpl'),array('type' => $type, 'elements' => $elements));}
|
||||
|
||||
public static function sai_mod_saimod_mojotrollz_db_tags(){
|
||||
$vars = array();
|
||||
$vars['PICPATH'] = \SYSTEM\WEBPATH(new \SYSTEM\PSAI(), 'modules/saimod_sys_log/img/');
|
||||
|
||||
@ -6,6 +6,6 @@
|
||||
<td>
|
||||
<button class="btn btn-success btn_type_edit" _id="${id}" _name="${name}" _description="${description}">Edit</button>
|
||||
<button class="btn btn-danger btn_type_del" _id="${id}" _table="${table}">Del</button>
|
||||
<button class="btn btn_type_values" _id="${id}" _table="${table}">Values</button>
|
||||
<button class="btn btn_type_values" _type="${id}">Values</button>
|
||||
</td>
|
||||
</tr>
|
||||
18
mojotrollz/sai/saimod_mojotrollz_db_tags/tpl/value_list.tpl
Normal file
18
mojotrollz/sai/saimod_mojotrollz_db_tags/tpl/value_list.tpl
Normal file
@ -0,0 +1,18 @@
|
||||
<h6>Tag Values of Tag Type ${type}</h6>
|
||||
<table class="sai_table">
|
||||
<tr>
|
||||
<th>id</th>
|
||||
<th>type</th>
|
||||
<th>value</th>
|
||||
<th>description</th>
|
||||
<th>action</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="input_value_id" type="number"/></td>
|
||||
<td>${type}</td>
|
||||
<td><input id="input_value_value" type="text"/></td>
|
||||
<td><input id="input_value_description" type="text"/></td>
|
||||
<td><button class="btn btn-danger" id="btn_value_add" _type="${type}">Add</button></td>
|
||||
</tr>
|
||||
${elements}
|
||||
</table>
|
||||
@ -0,0 +1,10 @@
|
||||
<tr>
|
||||
<td>${id}</td>
|
||||
<td>${type}</td>
|
||||
<td>${value}</td>
|
||||
<td>${description}</td>
|
||||
<td>
|
||||
<button class="btn btn-success btn_value_edit" _id="${id}" _value="${value}" _description="${description}">Edit</button>
|
||||
<button class="btn btn-danger btn_value_del" _id="${id}" _type="${type}">Del</button>
|
||||
</td>
|
||||
</tr>
|
||||
Loading…
x
Reference in New Issue
Block a user