|
|
@@ -23,18 +23,18 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
$namespace = V::get('namespace', '', $_GET);
|
|
|
if (empty($namespace)) throw new Exception("Missing param namespace");
|
|
|
// [idZasob] => 25872
|
|
|
- // [idDatabase] => 36
|
|
|
- // [namespace] => default_db/CRM_PROCES/CRM_PROCES
|
|
|
- // [_rootTableName] => CRM_PROCES
|
|
|
- // [_type] => AntAcl
|
|
|
- // [hasStruct] => 1
|
|
|
- // [isStructInstalled] => 1
|
|
|
- // [isObjectActive] => 1
|
|
|
- // [description] =>
|
|
|
- // [name] => CRM_PROCES
|
|
|
- // [nsPrefix] => default_db__x3A__CRM_PROCES
|
|
|
- // [typeName] => default_db__x3A__CRM_PROCES:CRM_PROCES
|
|
|
- // [reinstallLink] => https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=Storage&_task=objectReinstall&namespace=default_db/CRM_PROCES/CRM_PROCES
|
|
|
+ // [idDatabase] => 36
|
|
|
+ // [namespace] => default_db/CRM_PROCES/CRM_PROCES
|
|
|
+ // [_rootTableName] => CRM_PROCES
|
|
|
+ // [_type] => AntAcl
|
|
|
+ // [hasStruct] => 1
|
|
|
+ // [isStructInstalled] => 1
|
|
|
+ // [isObjectActive] => 1
|
|
|
+ // [description] =>
|
|
|
+ // [name] => CRM_PROCES
|
|
|
+ // [nsPrefix] => default_db__x3A__CRM_PROCES
|
|
|
+ // [typeName] => default_db__x3A__CRM_PROCES:CRM_PROCES
|
|
|
+ // [reinstallLink] => https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=Storage&_task=objectReinstall&namespace=default_db/CRM_PROCES/CRM_PROCES
|
|
|
$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
|
|
|
switch ($item['_type']) {
|
|
|
case 'TableAcl': $this->tableStructView($item, $item['name'], $item['idDatabase']); break;
|
|
|
@@ -42,7 +42,7 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
default: throw new Exception("Not implemented type"); break;
|
|
|
}
|
|
|
} catch (Exception $e) {
|
|
|
- UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
+ UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
DBG::log($e);
|
|
|
}
|
|
|
UI::endTag('div'); // .container-fluid
|
|
|
@@ -65,7 +65,7 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
|
|
|
$this->tableStructView($item, $tblName, $idStorage);
|
|
|
} catch (Exception $e) {
|
|
|
- UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
+ UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
}
|
|
|
UI::dol();
|
|
|
}
|
|
|
@@ -81,7 +81,7 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
$item = SchemaFactory::loadDefaultObject('SystemObject')->getItem($namespace, [ 'propertyName' => '*,field' ]);
|
|
|
$this->objectStructView($item);
|
|
|
} catch (Exception $e) {
|
|
|
- UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
+ UI::alert('danger', "Error #" . $e->getCode() . "|" . $e->getLine() . ": " . $e->getMessage());
|
|
|
DBG::log($e);
|
|
|
}
|
|
|
UI::endTag('div'); // .container-fluid
|
|
|
@@ -313,11 +313,41 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
|
|
|
public function objectStructView($item) {
|
|
|
$namespace = $item['namespace'];
|
|
|
- usort($item['field'], function ($a, $b) {
|
|
|
- if ($a['fieldNamespace'] > $b['fieldNamespace']) return 1;
|
|
|
- if ($a['fieldNamespace'] < $b['fieldNamespace']) return -1;
|
|
|
- return 0;
|
|
|
- });
|
|
|
+ { // sortBy
|
|
|
+ $sortByArgName = 'sortBy';
|
|
|
+ $sortByCol = V::get($sortByArgName, 'namespace', $_GET);
|
|
|
+ $sortByDir = V::get("{$sortByArgName}Dir", 'asc', $_GET);
|
|
|
+ { // add SORT_PRIO
|
|
|
+ $item['field'] = array_map(function ($field) {
|
|
|
+ $field['SORT_PRIO'] = ($field['idZasob'] > 0)
|
|
|
+ ? DB::getPDO()->fetchValue("
|
|
|
+ select z.SORT_PRIO
|
|
|
+ from CRM_LISTA_ZASOBOW z
|
|
|
+ where z.ID = :id
|
|
|
+ ", [ ':id' => $field['idZasob'] ])
|
|
|
+ : null
|
|
|
+ ;
|
|
|
+ return $field;
|
|
|
+ }, $item['field']);
|
|
|
+ }
|
|
|
+ if ('namespace' === $sortByCol) {
|
|
|
+ usort($item['field'], function ($a, $b) use ($sortByDir) {
|
|
|
+ if ($a['fieldNamespace'] > $b['fieldNamespace']) return 'asc' === $sortByDir ? 1 : -1;
|
|
|
+ if ($a['fieldNamespace'] < $b['fieldNamespace']) return 'asc' === $sortByDir ? -1 : 1;
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else if ('sort' === $sortByCol) {
|
|
|
+ usort($item['field'], function ($a, $b) use ($sortByDir) {
|
|
|
+ if (null === $a['SORT_PRIO'] && null === $b['SORT_PRIO']) return 0;
|
|
|
+ if (null === $a['SORT_PRIO'] && null != $b['SORT_PRIO']) return 1;
|
|
|
+ if (null !== $a['SORT_PRIO'] && null === $b['SORT_PRIO']) return -1;
|
|
|
+ if ($a['SORT_PRIO'] > $b['SORT_PRIO']) return 'asc' === $sortByDir ? 1 : -1;
|
|
|
+ if ($a['SORT_PRIO'] < $b['SORT_PRIO']) return 'asc' === $sortByDir ? -1 : 1;
|
|
|
+ return 0;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if ('setFieldRefConfig' === V::get('_postTask', '', $_POST)) {
|
|
|
$field = V::get('field', '', $_POST);
|
|
|
@@ -540,12 +570,50 @@ class Route_Storage_AclStruct extends RouteBase {
|
|
|
}, $refFields)
|
|
|
]);
|
|
|
}
|
|
|
+
|
|
|
+ echo UI::h('script', [ 'src' => "static/URI.js" ]);
|
|
|
+ echo UI::h('script', [], "
|
|
|
+ function p5UI_table_sortBy_get(n, argName, colName, dir) {
|
|
|
+ console.log('TODO p5UI_table_sortBy_get :: window.location', window.location)
|
|
|
+ var newUri = URI(window.location.href).setQuery(argName, colName).setQuery(argName+'Dir', dir).build().toString();
|
|
|
+ console.log('TODO p5UI_table_sortBy_get :: uri', newUri)
|
|
|
+ window.location.href = newUri
|
|
|
+ }
|
|
|
+ ");
|
|
|
+ echo UI::h('style', [ 'type' => "text/css" ], "
|
|
|
+ .ta-ordering { cursor:pointer }
|
|
|
+ .ta-ordering-desc:after { content:\"\\e252\"; font-family:\"Glyphicons Halflings\"; line-height:1; margin:0 0 0 3px; display:inline-block; color:#bbb }
|
|
|
+ .ta-ordering-asc:after { content:\"\\e253\"; font-family:\"Glyphicons Halflings\"; line-height:1; margin:0 0 0 3px; display:inline-block; color:#bbb }
|
|
|
+ ");
|
|
|
UI::table([
|
|
|
'caption' => UI::h('span', [], [
|
|
|
UI::h('span', [ 'style' => "margin-right:6px;color:#000" ], "Struktura obiektu '{$item['namespace']}'"),
|
|
|
]),
|
|
|
+ // 'sortBy' => [
|
|
|
+ // 'method' => 'get',
|
|
|
+ // 'argName' => '_sortBy',
|
|
|
+ // 'allow' => ['sort', 'namespace'],
|
|
|
+ // 'default' => ['namespace', 'asc'],
|
|
|
+ // ],
|
|
|
+ 'cols_label' => [
|
|
|
+ 'sort' => UI::h('nobr', [
|
|
|
+ 'class' => "ta-ordering" . ('sort' === $sortByCol ? " ta-ordering-" . ( 'asc' === $sortByDir ? 'asc' : 'desc' ) : '' ),
|
|
|
+ 'onClick' => "return p5UI_table_sortBy_get(this, '{$sortByArgName}', 'sort', '" . ('sort' === $sortByCol ? ( 'asc' === $sortByDir ? 'desc' : 'asc' ) : 'asc' ) . "')",
|
|
|
+ 'title' => "Sortuj wg pola SORT_PRIO z zasobów",
|
|
|
+ ], "sort"),
|
|
|
+ 'namespace' => UI::h('nobr', [
|
|
|
+ 'class' => "ta-ordering" . ('namespace' === $sortByCol ? " ta-ordering-" . ( 'asc' === $sortByDir ? 'asc' : 'desc' ) : '' ),
|
|
|
+ 'onClick' => "return p5UI_table_sortBy_get(this, '{$sortByArgName}', 'namespace', '" . ('namespace' === $sortByCol ? ( 'asc' === $sortByDir ? 'desc' : 'asc' ) : 'asc' ) . "')",
|
|
|
+ 'title' => "Sortuj wg pola SORT_PRIO z zasobów",
|
|
|
+ ], "namespace"),
|
|
|
+ ],
|
|
|
'rows' => array_map(function ($field) use ($item, $thisGetLink) {
|
|
|
- $tblItem = []; foreach ($field as $k => $v) $tblItem[$k] = $v;
|
|
|
+ $tblItem = [];
|
|
|
+ $tblItem['sort'] = V::get('SORT_PRIO', null, $field);
|
|
|
+ foreach ($field as $k => $v) {
|
|
|
+ if ('SORT_PRIO' === $k) continue;
|
|
|
+ $tblItem[$k] = $v;
|
|
|
+ }
|
|
|
$tblItem['namespace'] = UI::h('span', [], [
|
|
|
UI::h('span', ['style' => "color:#aaa"], substr($field['namespace'], 0, strlen($field['objectNamespace']) + 1)),
|
|
|
UI::h('span', ['style' => "color:#000"], substr($field['namespace'], strlen($field['objectNamespace']) + 1)),
|