diff --git a/module/space/config/dtable.php b/module/space/config/dtable.php index 1b6ce6c314..7541586248 100644 --- a/module/space/config/dtable.php +++ b/module/space/config/dtable.php @@ -10,16 +10,18 @@ $config->space->dtable = new stdclass(); $config->space->dtable->fieldList['name']['title'] = $lang->instance->name; $config->space->dtable->fieldList['name']['type'] = 'title'; -$config->space->dtable->fieldList['appName']['title'] = $lang->instance->appName; -$config->space->dtable->fieldList['appName']['type'] = 'text'; -$config->space->dtable->fieldList['appName']['width'] = '90'; +$config->space->dtable->fieldList['appName']['title'] = $lang->instance->appName; +$config->space->dtable->fieldList['appName']['type'] = 'text'; +$config->space->dtable->fieldList['appName']['width'] = '90'; +$config->space->dtable->fieldList['appName']['sortType'] = true; -$config->space->dtable->fieldList['status']['name'] = 'status'; -$config->space->dtable->fieldList['status']['title'] = $lang->space->status; -$config->space->dtable->fieldList['status']['type'] = 'category'; -$config->space->dtable->fieldList['status']['map'] = $lang->instance->statusList; -$config->space->dtable->fieldList['status']['group'] = 'status'; -$config->space->dtable->fieldList['status']['width'] = '80'; +$config->space->dtable->fieldList['status']['name'] = 'status'; +$config->space->dtable->fieldList['status']['title'] = $lang->space->status; +$config->space->dtable->fieldList['status']['type'] = 'category'; +$config->space->dtable->fieldList['status']['map'] = $lang->instance->statusList; +$config->space->dtable->fieldList['status']['group'] = 'status'; +$config->space->dtable->fieldList['status']['width'] = '80'; +$config->space->dtable->fieldList['status']['sortType'] = true; $config->space->dtable->fieldList['appVersion']['title'] = $lang->store->appVersion; $config->space->dtable->fieldList['appVersion']['type'] = 'text'; diff --git a/module/space/control.php b/module/space/control.php index f2e93acfc9..5a8561dc67 100644 --- a/module/space/control.php +++ b/module/space/control.php @@ -90,12 +90,14 @@ class space extends control $this->view->title = $this->lang->space->common; $this->view->position[] = $this->lang->space->common; $this->view->pager = $pager; + $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; $this->view->spaceType = $spaceType; $this->view->instances = (empty($allInstances) or empty($allInstances[$pageID - 1])) ? array() : $allInstances[$pageID - 1]; $this->view->currentSpace = $space; $this->view->searchName = $search; $this->view->users = $this->loadModel('user')->getPairs('noclosed,noletter'); + $this->view->sortLink = $this->createLink('space', 'browse', "spaceID=&browseType={$browseType}&orderBy={orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}"); $this->display(); } diff --git a/module/space/js/browse.ui.js b/module/space/js/browse.ui.js index 5824caa8f2..a3d8c61bc6 100644 --- a/module/space/js/browse.ui.js +++ b/module/space/js/browse.ui.js @@ -89,3 +89,10 @@ window.editApp = function(externalID, appName) } $('#editLinkContainer').trigger('click'); } + +window.createSortLink = function(col) +{ + var sort = col.name + '_asc'; + if(sort == orderBy) sort = col.name + '_desc'; + return sortLink.replace('{orderBy}', sort); +} diff --git a/module/space/ui/browse.html.php b/module/space/ui/browse.html.php index 8971e30f3d..e7c16a928a 100644 --- a/module/space/ui/browse.html.php +++ b/module/space/ui/browse.html.php @@ -10,6 +10,9 @@ declare(strict_types=1); */ namespace zin; +jsVar('orderBy', $orderBy); +jsVar('sortLink', $sortLink); + $statusMap = array(); $canInstall = hasPriv('instance', 'install'); @@ -49,6 +52,7 @@ dtable set::cols($config->space->dtable->fieldList), set::data($instances), set::onRenderCell(jsRaw('window.renderInstanceList')), + set::sortLink(jsRaw('createSortLink')), set::footPager(usePager()), );