Bläddra i källkod

Добавлено отображение даты поступления

Book Pauk 2 år sedan
förälder
incheckning
c3724feba0

+ 2 - 2
client/components/Search/BaseList.js

@@ -50,7 +50,7 @@ export default class BaseList {
     expandedSeries = [];
 
     showCounts = true;
-    showRate = true;
+    showRates = true;
     showGenres = true;    
     showDeleted = false;
     abCacheEnabled = true;
@@ -81,7 +81,7 @@ export default class BaseList {
         this.expandedAuthor = _.cloneDeep(settings.expandedAuthor);
         this.expandedSeries = _.cloneDeep(settings.expandedSeries);
         this.showCounts = settings.showCounts;
-        this.showRate = settings.showRate;
+        this.showRates = settings.showRates;
         this.showGenres = settings.showGenres;
         this.showDeleted = settings.showDeleted;
         this.abCacheEnabled = settings.abCacheEnabled;

+ 20 - 4
client/components/Search/BookView/BookView.vue

@@ -1,8 +1,8 @@
 <template>
     <div class="row items-center q-my-sm">
         <div class="row items-center no-wrap">
-            <div v-if="showRate || showDeleted">
-                <div v-if="showRate && !book.del">
+            <div v-if="showRates || showDeleted">
+                <div v-if="showRates && !book.del">
                     <div v-if="book.librate">
                         <q-knob
                             :model-value="book.librate"
@@ -76,6 +76,10 @@
             {{ bookGenre }}
         </div>
 
+        <div v-if="showDates && book.date" class="q-ml-sm">
+            {{ bookDate }}
+        </div>
+
         <div v-show="false">
             {{ book }}
         </div>
@@ -86,6 +90,8 @@
 //-----------------------------------------------------------------------------
 import vueComponent from '../../vueComponent.js';
 
+import * as utils from '../../../share/utils';
+
 const componentOptions = {
     components: {
     },
@@ -106,9 +112,10 @@ class BookView {
         titleColor: { type: String, default: 'text-blue-10'},
     };
 
-    showRate = true;
+    showRates = true;
     showGenres = true;
     showDeleted = false;
+    showDates = false;
 
     created() {
         this.loadSettings();
@@ -117,8 +124,9 @@ class BookView {
     loadSettings() {
         const settings = this.settings;
 
-        this.showRate = settings.showRate;
+        this.showRates = settings.showRates;
         this.showGenres = settings.showGenres;
+        this.showDates = settings.showDates;
         this.showDeleted = settings.showDeleted;
     }
 
@@ -174,6 +182,14 @@ class BookView {
         return `(${result.join(' / ')})`;
     }
 
+    get bookDate() {
+        if (!this.book.date)
+            return '';
+
+        const date = utils.parseDate(this.book.date);
+        return utils.formatDate(date, 'noDate');
+    }
+
     selectAuthor() {
         this.$emit('bookEvent', {action: 'authorClick', book: this.book});
     }

+ 28 - 16
client/components/Search/Search.vue

@@ -30,15 +30,19 @@
                     />
 
                     <DivBtn class="q-ml-md text-white bg-secondary" :size="30" :icon-size="24" :imt="1" icon="la la-cog" round @click="settingsDialogVisible = true">
-                        <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
-                            Настройки
-                        </q-tooltip>
+                        <template #tooltip>
+                            <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
+                                Настройки
+                            </q-tooltip>
+                        </template>
                     </DivBtn>
 
                     <DivBtn class="q-ml-sm text-white bg-secondary" :size="30" :icon-size="24" icon="la la-question" round @click="showSearchHelp">
-                        <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
-                            Памятка
-                        </q-tooltip>
+                        <template #tooltip>
+                            <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
+                                Памятка
+                            </q-tooltip>
+                        </template>
                     </DivBtn>
 
                     <div class="col"></div>
@@ -90,13 +94,15 @@
 
                     <div class="q-mx-xs" />
                     <DivBtn
-                        class="text-white bg-info q-mt-xs" :size="34" :icon-size="24" :imt="1" 
+                        class="text-grey-5 bg-yellow-1 q-mt-xs" :size="34" :icon-size="24" round
                         :icon="(extendedParams ? 'la la-angle-double-up' : 'la la-angle-double-down')"
                         @click="extendedParams = !extendedParams"
                     >
-                        <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
-                            {{ `${(extendedParams ? 'Скрыть' : 'Показать')} дополнительные критерии поиска` }}
-                        </q-tooltip>
+                        <template #tooltip>
+                            <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%" max-width="400px">
+                                {{ `${(extendedParams ? 'Скрыть' : 'Показать')} дополнительные критерии поиска` }}
+                            </q-tooltip>
+                        </template>
                     </DivBtn>
                 </div>
                 <div v-show="extendedParams" class="row q-mx-md q-mb-xs items-center">
@@ -188,8 +194,9 @@
                 </div>
 
                 <q-checkbox v-model="showCounts" size="36px" label="Показывать количество" />                
-                <q-checkbox v-model="showRate" size="36px" label="Показывать оценки" />
+                <q-checkbox v-model="showRates" size="36px" label="Показывать оценки" />
                 <q-checkbox v-model="showGenres" size="36px" label="Показывать жанры" />
+                <q-checkbox v-model="showDates" size="36px" label="Показывать даты поступления" />
                 <q-checkbox v-model="showDeleted" size="36px" label="Показывать удаленные" />
                 <q-checkbox v-model="abCacheEnabled" size="36px" label="Кешировать запросы" />
             </div>
@@ -279,12 +286,15 @@ const componentOptions = {
         showCounts(newValue) {
             this.setSetting('showCounts', newValue);
         },
-        showRate(newValue) {
-            this.setSetting('showRate', newValue);
+        showRates(newValue) {
+            this.setSetting('showRates', newValue);
         },
         showGenres(newValue) {
             this.setSetting('showGenres', newValue);
         },
+        showDates(newValue) {
+            this.setSetting('showDates', newValue);
+        },
         showDeleted(newValue) {
             this.setSetting('showDeleted', newValue);
         },
@@ -368,8 +378,9 @@ class Search {
 
     //settings
     showCounts = true;
-    showRate = true;
-    showGenres = true;    
+    showRates = true;
+    showGenres = true;
+    showDates = true;
     showDeleted = false;
     abCacheEnabled = true;
     langDefault = '';
@@ -447,8 +458,9 @@ class Search {
         this.expanded = _.cloneDeep(settings.expanded);
         this.expandedSeries = _.cloneDeep(settings.expandedSeries);
         this.showCounts = settings.showCounts;
-        this.showRate = settings.showRate;
+        this.showRates = settings.showRates;
         this.showGenres = settings.showGenres;
+        this.showDates = settings.showDates;
         this.showDeleted = settings.showDeleted;
         this.abCacheEnabled = settings.abCacheEnabled;
         this.langDefault = settings.langDefault;

+ 1 - 0
client/components/share/DivBtn.vue

@@ -4,6 +4,7 @@
             <i :class="icon" :style="`font-size: ${iconSize}px; margin-top: ${imt}px`" />
             <slot></slot>
         </div>
+        <slot name="tooltip"></slot>
     </div>
 </template>
 

+ 27 - 0
client/share/utils.js

@@ -98,3 +98,30 @@ export function makeValidFilename(filename, repl = '_') {
     else
         throw new Error('Invalid filename');
 }
+
+export function formatDate(d, format = 'normal') {
+    switch (format) {
+        case 'normal':
+            return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()} ` + 
+                `${d.getHours().toString().padStart(2, '0')}:${d.getMinutes().toString().padStart(2, '0')}`;
+        case 'coDate':
+            return `${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, '0')}-${d.getDate().toString().padStart(2, '0')}`;
+        case 'coMonth':
+            return `${(d.getMonth() + 1).toString().padStart(2, '0')}`;
+        case 'noDate':
+            return `${d.getDate().toString().padStart(2, '0')}.${(d.getMonth() + 1).toString().padStart(2, '0')}.${d.getFullYear()}`;
+
+        default:
+            throw new Error('formatDate: unknown date format');
+    }
+}
+
+export function parseDate(sqlDate) {
+    const d = sqlDate.split('-');
+    const result = new Date();
+    result.setDate(parseInt(d[2], 10));
+    result.setMonth(parseInt(d[1], 10) - 1);
+    result.setYear(parseInt(d[0], 10));
+        
+    return result;
+}

+ 2 - 1
client/store/root.js

@@ -8,8 +8,9 @@ const state = {
         expandedAuthor: [],
         expandedSeries: [],
         showCounts: true,
-        showRate: true,
+        showRates: true,
         showGenres: true,
+        showDates: false,
         showDeleted: false,
         abCacheEnabled: true,
         langDefault: '',