]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
new sort direction field in collection edit view
authorBanana <mail@bananas-playground.net>
Fri, 16 Dec 2022 18:32:15 +0000 (19:32 +0100)
committerBanana <mail@bananas-playground.net>
Fri, 16 Dec 2022 18:32:15 +0000 (19:32 +0100)
CHANGELOG
documentation/setup/bibliotheca.sql
upgrade/from-version-1.3.tx [new file with mode: 0644]
webclient/lib/managecollections.class.php
webclient/lib/trite.class.php
webclient/view/default/collections/collections.html
webclient/view/default/collections/collections.php
webclient/view/default/managecolletions/managecolletions.html
webclient/view/default/managecolletions/managecolletions.php

index 68b185af82bff3d2922c3cb870419eaa885d2fb2..a3f4cb94e5501c25cc161b181fd1b7d284e1d026 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,7 @@
 1.4 - Depths Of Rrajigar
+       * Added new default sort direction field in collection edit view. See upgrade file for more needed details
+       * Fixed #13
+       * Fixed Some layout alignements
 
 1.3 - Rrajigar Mine 2022-10-08
        * Fixed install sql file.
index 2f3ee6c47270b7f61817eaa619c23a05f44041e0..f67bfa3a519d6b286e2e234e9b9e7da80e6c0689 100644 (file)
@@ -34,6 +34,7 @@ CREATE TABLE `#REPLACEME#_collection` (
   `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   `defaultSearchField` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   `defaultSortField` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+  `defaultSortOrder` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
   `advancedSearchTableFields` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `modified` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
diff --git a/upgrade/from-version-1.3.tx b/upgrade/from-version-1.3.tx
new file mode 100644 (file)
index 0000000..301b8e4
--- /dev/null
@@ -0,0 +1,3 @@
+# DB changes. Run each line against your bibliotheca DB.
+# Replace #REPLACEME# with your table prefix. Default is bib
+ALTER TABLE `#REPLACEME#_collection` ADD `defaultSortOrder` VARCHAR(4) CHARACTER SET utf8mb4_unicode_ci COLLATE utf8mb4_bin NOT NULL AFTER `defaultSortField`;
index 6c4014158e269fdcb06f6047a22a54a8ff92d005..c744e06a8c443d34fd0af289858e13659fbfcbfa 100644 (file)
@@ -184,6 +184,7 @@ class ManageCollections {
                                                                `rights` = '".$this->_DB->real_escape_string($data['rights'])."',
                                                                `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."',
                                                                `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."',
+                                                               `defaultSortOrder` = '".$this->_DB->real_escape_string($data['defaultSortOrder'])."',
                                                                `advancedSearchTableFields` = '".$this->_DB->real_escape_string($data['advancedSearchTableFields'])."'";
                                if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
                                $this->_DB->query($queryStr);
@@ -252,6 +253,7 @@ class ManageCollections {
                        $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`,
                                        `c`.`owner`, `c`.`group`, `c`.`rights`, `c`.`defaultSearchField`,
                                        `c`.`defaultSortField`, `c`.`advancedSearchTableFields`,
+                                       `c`.`defaultSortOrder`,
                                        `u`.`name` AS username, `g`.`name` AS groupname
                                        FROM `".DB_PREFIX."_collection` AS c
                                        LEFT JOIN `".DB_PREFIX."_user` AS u ON `c`.`owner` = `u`.`id`
@@ -300,6 +302,7 @@ class ManageCollections {
                                                        `rights` = '".$this->_DB->real_escape_string($data['rights'])."',
                                                        `defaultSearchField` = '".$this->_DB->real_escape_string($data['defaultSearchField'])."',
                                                        `defaultSortField` = '".$this->_DB->real_escape_string($data['defaultSortField'])."',
+                                                       `defaultSortOrder` = '".$this->_DB->real_escape_string($data['defaultSortOrder'])."',
                                                        `advancedSearchTableFields` = '".$this->_DB->real_escape_string($data['advancedSearchTableFields'])."'
                                                WHERE `id` = '".$this->_DB->real_escape_string($data['id'])."'";
                        if(QUERY_DEBUG) error_log("[QUERY] ".__METHOD__." query: ".var_export($queryStr,true));
index 0c42f588bed48d16c799f0efae78eba7b45c8f8c..48f97e04b24057e660d0a81ef518bbe6af35d69c 100644 (file)
@@ -120,6 +120,7 @@ class Trite {
                        $queryStr = "SELECT `c`.`id`, `c`.`name`, `c`.`description`, `c`.`created`,
                                        `c`.`owner`, `c`.`group`, `c`.`rights`, `c`.`defaultSearchField`,
                                        `c`.`defaultSortField`,`c`.`advancedSearchTableFields`,
+                                       `c`.`defaultSortOrder`,
                                        `u`.`name` AS username, `g`.`name` AS groupname
                                        FROM `".DB_PREFIX."_collection` AS c
                                        LEFT JOIN `".DB_PREFIX."_user` AS u ON `c`.`owner` = `u`.`id`
index b8c1059a73afdc0a24622ee731b90fecee998c4c..5f32bc9ddc8dd8a316b64aa4e80144256bbd735c 100644 (file)
@@ -11,7 +11,7 @@
                        <div uk-dropdown>
                                <ul class="uk-nav uk-dropdown-nav">
                                        <?php if(!empty($TemplateData['defaultSortField'])) { ?>
-                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('s'=>$TemplateData['defaultSortField'],'sd'=>'ASC')); ?>">Default</a></li>
+                                       <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('s'=>$TemplateData['defaultSortField'],'sd'=>$TemplateData['defaultSortOrder'])); ?>">Default</a></li>
                                        <?php } else { ?>
                                        <li><a href="index.php?<?php echo Summoner::createFromParameterLinkQuery($TemplateData['pagination']['currentGetParameters'],array('s'=>'','sd'=>'ASC')); ?>">Latest</a></li>
                                        <?php } ?>
index 5906b50403359c6499aea353bff302fb24b2a61b..7b61328a885e79167c1746f6709ad71e07082ecc 100644 (file)
@@ -62,7 +62,7 @@ if(isset($_GET['s']) && !empty($_GET['s'])) {
        $_sort = Summoner::validate($_sort,'nospace') ? $_sort : false;
 }
 
-$_sortDirection = false;
+$_sortDirection = '';
 if(isset($_GET['sd']) && !empty($_GET['sd'])) {
        $_sortDirection = trim($_GET['sd']);
        $_sortDirection = Summoner::validate($_sortDirection,'nospace') ? $_sortDirection : false;
@@ -91,7 +91,8 @@ if(!empty($_collection)) {
        if(!empty($TemplateData['loadedCollection'])) {
                $Mancubus->setCollection($Trite->param('id'));
 
-               $TemplateData['defaultSortField'] = $defaultSortField = $Trite->param('defaultSortField');
+               $TemplateData['defaultSortField'] = $Trite->param('defaultSortField');
+               $TemplateData['defaultSortOrder'] = $Trite->param('defaultSortOrder');
                $TemplateData['simpleSearchFields'] = $Trite->getSimpleSearchFields();
                if(!empty($_queryOptions['sort'])) {
                        $TemplateData['simpleSearchFields'][$_queryOptions['sort']]['selected'] = true;
@@ -102,6 +103,11 @@ if(!empty($_collection)) {
                                $_queryOptions['sort'] = $TemplateData['defaultSortField'];
                        }
                }
+               if(!empty($TemplateData['defaultSortOrder'])) {
+                       if(empty($_queryOptions['sortDirection'])) {
+                               $_queryOptions['sortDirection'] = $TemplateData['defaultSortOrder'];
+                       }
+               }
 
                $Mancubus->setQueryOptions($_queryOptions);
 
index 16b5ee905a1803e8ddf1e701bae225d809637581..3888c99b0634dcb8ab81e9a268084f46cb0977dc 100644 (file)
                                        </select>
                                </div>
                        </div>
+                       <div class="uk-margin">
+                               <label class="uk-form-label" for="defaultSortField">Default sort order</label>
+                               <div class="uk-form-controls">
+                                       <select class="uk-select" id="defaultSortOrder" name="fdata[defaultSortOrder]">
+                                               <option value="ASC" <?php if(Summoner::ifsetValue($TemplateData['editData'], 'defaultSortOrder', 'ASC')) echo 'selected'; ?>>ASCENDING</option>
+                                               <option value="DESC" <?php if(Summoner::ifsetValue($TemplateData['editData'], 'defaultSortOrder', 'DESC')) echo 'selected'; ?>>DESCENDING</option>
+                                       </select>
+                               </div>
+                       </div>
                        <div class="uk-margin">
                                <label class="uk-form-label" for="advancedSearchTableFields">Table advanced search view</label>
                                <div class="uk-form-controls">
index 1dd057ea66ff74ecaf431487794a171859292fb1..58864e101a675dc4009b53b9c1052ecd82ae5e9f 100644 (file)
@@ -69,6 +69,7 @@ if(isset($_POST['submitForm'])) {
                $_saveData['rights'] = Summoner::prepareRightsString($fdata['rights']);
                $_saveData['defaultSearchField'] = $fdata['defaultSearchField'];
                $_saveData['defaultSortField'] = $fdata['defaultSortField'];
+               $_saveData['defaultSortOrder'] = $fdata['defaultSortOrder'];
                $_saveData['id'] = $_id;
 
                $_saveData['tool'] = array();