|
|
@@ -658,7 +658,7 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
$thisGetLink = [ $this, 'getLink' ];
|
|
|
{ // not installed ref
|
|
|
$refFields = array_filter($item['field'], function ($field) {
|
|
|
- return 'ref:' === substr($field['xsdType'], 0, 4);
|
|
|
+ return ('ref:' === substr($field['xsdType'], 0, 4) && $field['isActive']);
|
|
|
});
|
|
|
UI::table([
|
|
|
'caption' => UI::h('span', [], "Obiekty powiązane (TODO backRef)"),
|
|
|
@@ -782,8 +782,65 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
unset($tblItem['objectNamespace']);
|
|
|
unset($tblItem['fieldNamespace']);
|
|
|
return $tblItem;
|
|
|
- }, $item['field'])
|
|
|
+ }, array_filter($item['field'], function ($field) { return $field['isActive']; }))
|
|
|
]);
|
|
|
+ $removedFields = array_filter($item['field'], function ($field) { return !$field['isActive']; });
|
|
|
+ if (!empty($removedFields)) {
|
|
|
+ // echo UI::h('details', [ 'style' => "padding:6px; background-color:#333; color:#fff", 'open' => "open" ], [
|
|
|
+ // UI::h('summary', [ 'style' => "padding:0 3px; outline:none; cursor:pointer" ], "WFS Response converted to JSON"),
|
|
|
+ // UI::h('pre', [ 'id' => 'wfsResponse', 'style' => "margin:0; font-size:x-small; border-radius:0" ], 'loading...'),
|
|
|
+ echo UI::h('details', [ 'style' => "margin-bottom:12px; padding:6px; background-color:#dedede; color:#000" ], [
|
|
|
+ UI::h('summary', [ 'style' => "padding:0 3px; outline:none; cursor:pointer" ], "Pola w koszu (".count($removedFields).")"),
|
|
|
+ UI::h('table', [ 'style' => "margin:6px 0 0 0; background-color:#fff; font-size:x-small", 'class' => "table table-bordered table-hover table-condensed" ], [
|
|
|
+ UI::h('thead', [], [
|
|
|
+ UI::h('tr', [], [
|
|
|
+ UI::h('th', [], "#"),
|
|
|
+ UI::h('th', [], "namespace"),
|
|
|
+ UI::h('th', [], "xsdType"),
|
|
|
+ UI::h('th', [], "xsdRestrictions"),
|
|
|
+ UI::h('th', [], "appInfo"),
|
|
|
+ UI::h('th', [], "minOccurs"),
|
|
|
+ UI::h('th', [], "maxOccurs"),
|
|
|
+ UI::h('th', [], "isActive"),
|
|
|
+ ]),
|
|
|
+ ]),
|
|
|
+ UI::h('tbody', [], array_map(function ($field) use ($item, $thisGetLink) {
|
|
|
+ return UI::h('tr', [], [
|
|
|
+ UI::h('td', [], [
|
|
|
+ UI::hButtonAjax("usuń", 'removeFieldFromTrashAjax', [
|
|
|
+ 'class' => "btn btn-xs btn-danger",
|
|
|
+ 'href' => $thisGetLink('removeFieldFromTrashAjax'),
|
|
|
+ 'data' => [
|
|
|
+ 'namespace' => $item['namespace'],
|
|
|
+ 'fieldNamespace' => $field['namespace'],
|
|
|
+ ]
|
|
|
+ ])
|
|
|
+ ]),
|
|
|
+ UI::h('td', [], $field['fieldNamespace']),
|
|
|
+ UI::h('td', [], $field['xsdType']),
|
|
|
+ UI::h('td', [], $field['xsdRestrictions']),
|
|
|
+ UI::h('td', [], $field['appInfo']),
|
|
|
+ UI::h('td', [], $field['minOccurs']),
|
|
|
+ UI::h('td', [], $field['maxOccurs']),
|
|
|
+ UI::h('td', [], $field['isActive']),
|
|
|
+ ]);
|
|
|
+ }, $removedFields)),
|
|
|
+ ]),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ UI::hButtonAjaxOnResponse('removeFieldFromTrashAjax', /* payload, n */ "
|
|
|
+ if (!payload.type) return false
|
|
|
+ jQuery.notify(payload.msg, payload.type)
|
|
|
+ if ('success' == payload.type) {
|
|
|
+ var trJqNode = jQuery(n).closest('tr')
|
|
|
+ var tbodyJqNode = trJqNode.parent()
|
|
|
+ var detailsJqNode = trJqNode.closest('details')
|
|
|
+ trJqNode.remove()
|
|
|
+ if (!tbodyJqNode.children().length) {
|
|
|
+ detailsJqNode.remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ");
|
|
|
UI::hButtonAjaxOnResponse('addFieldToZasobyAjax', /* payload, n */ "
|
|
|
if (!payload.type) return false
|
|
|
if (payload.body && payload.body.id && payload.body.id > 0) { // if ('success' == payload.type) {
|
|
|
@@ -952,6 +1009,44 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ public function removeFieldFromTrashAjaxAction() {
|
|
|
+ DBG::log($_REQUEST, 'array', '$_REQUEST');
|
|
|
+ Response::sendTryCatchJson(array($this, 'removeFieldFromTrashAjax'), $_REQUEST);
|
|
|
+ }
|
|
|
+ public function removeFieldFromTrashAjax($args) {
|
|
|
+ $namespace = V::get('namespace', '', $args);
|
|
|
+ if (empty($namespace)) throw new HttpException("Missing namespace");
|
|
|
+ $fieldNamespace = V::get('fieldNamespace', '', $args);
|
|
|
+ if (empty($fieldNamespace)) throw new HttpException("Missing fieldNamespace");
|
|
|
+ $fieldItem = SchemaFactory::loadDefaultObject('SystemObjectField')->getItem($fieldNamespace);
|
|
|
+ if (!$fieldItem) throw new HttpException("Field not found '{$fieldNamespace}'", 404);
|
|
|
+ DBG::log($fieldItem, 'array', "\$fieldItem");
|
|
|
+ switch ($fieldItem['xsdType']) {
|
|
|
+ case 'p5:enum': throw new Exception("TODO: remove enum values first"); break; // CRM_#CACHE_ACL_OBJECT_FIELD_enum
|
|
|
+ default: {
|
|
|
+ if ('ref:' === substr($fieldItem['xsdType'], 0, 4)) { // OK, remove
|
|
|
+ } else throw new Exception("TODO: remove xsdType: {$fieldItem['xsdType']}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ DB::getPDO()->execSql("
|
|
|
+ DELETE from `CRM_#CACHE_ACL_OBJECT_FIELD`
|
|
|
+ where namespace = :namespace
|
|
|
+ and objectNamespace = :objectNamespace
|
|
|
+ and _rootTableName = :rootTableName
|
|
|
+ and isActive = 0
|
|
|
+ limit 1
|
|
|
+ ", [
|
|
|
+ 'namespace' => $fieldItem['namespace'],
|
|
|
+ 'objectNamespace' => $fieldItem['objectNamespace'],
|
|
|
+ 'rootTableName' => $fieldItem['_rootTableName'],
|
|
|
+ ]);
|
|
|
+ return [
|
|
|
+ 'type' => "success",
|
|
|
+ 'msg' => "Usunięto pole {$fieldItem['fieldNamespace']}",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
public function addFieldToZasobyAjaxAction() {
|
|
|
DBG::log($_REQUEST, 'array', '$_REQUEST');
|
|
|
Response::sendTryCatchJson(array($this, 'addFieldToZasobyAjax'), $_REQUEST);
|