@christianriedl/media 1.0.185 → 1.0.186

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/media",
3
- "version": "1.0.185",
3
+ "version": "1.0.186",
4
4
  "description": "RIC media interfaces",
5
5
 
6
6
  "main": "dist/index.js",
@@ -15,17 +15,18 @@
15
15
  const selectedAuthor = ref<IAuthorShort | string | undefined>();
16
16
  const currentAuthor = reactive<IAuthor>({ id: 0, surName: "", givenName: "", yearOfBirth: 0, books: [] });
17
17
  const selectedBook = ref<IBook>({ id: 0, authorId: 0, title: ""});
18
- let newBook: IBook;
19
18
  const allBooks = ref<IBook[]>([]);
20
19
  const lastAllBooksId = ref(0);
21
20
  const mustAddAuthor = ref(false);
22
21
  const mustUpdateAuthor = ref(false);
23
22
  const showAddBookLine = ref(false);
24
23
  const showSelectedBook = ref(false);
25
- let setBookChanged: () => void;
26
- let readonly = !(appState.scopes & EScope.Admin);
27
- let isMobile = appState.isMobile && (appState.device != EDevice.iPad);
24
+ const sortedByYear = ref(false);
25
+ const readonly = !(appState.scopes & EScope.Admin);
26
+ const isMobile = appState.isMobile && (appState.device != EDevice.iPad);
28
27
  const heightStyle = computed<StyleValue>(() => { return { height: appState.bodyHeight.value + "px", overflowY: "auto" } });
28
+ let newBook: IBook;
29
+ let setBookChanged: () => void;
29
30
 
30
31
  start();
31
32
 
@@ -94,6 +95,9 @@
94
95
  currentAuthor.category = a.category;
95
96
  currentAuthor.country = a.country;
96
97
  currentAuthor.books = a.books ? a.books : [];
98
+ if (sortedByYear.value) {
99
+ currentAuthor.books = sortBooks (currentAuthor.books, true);
100
+ }
97
101
  return true;
98
102
  }
99
103
  else {
@@ -348,6 +352,24 @@
348
352
  return "";
349
353
  }
350
354
  }
355
+ function sortByTitle () {
356
+ if (sortedByYear.value && currentAuthor.books) {
357
+ currentAuthor.books = sortBooks (currentAuthor.books, false);
358
+ sortedByYear.value = false;
359
+ }
360
+ }
361
+ function sortByYear () {
362
+ if (!sortedByYear.value && currentAuthor.books) {
363
+ currentAuthor.books = sortBooks (currentAuthor.books, true);
364
+ sortedByYear.value = true;
365
+ }
366
+ }
367
+ function sortBooks (books: IBook[], byYear: boolean) : IBook[] {
368
+ if (byYear)
369
+ return books.sort ((a, b) => (a.year || 0) - (b.year || 0));
370
+ else
371
+ return books.sort ((a, b) => a.title.localeCompare(b.title));
372
+ }
351
373
  </script>
352
374
 
353
375
  <template>
@@ -410,8 +432,14 @@
410
432
  <v-col cols="3">JAHR</v-col>
411
433
  </v-row>
412
434
  <v-row v-else dense align="center" class="bg-office" >
413
- <v-col cols="6">TITEL</v-col>
414
- <v-col cols="1">JAHR</v-col>
435
+ <v-col cols="6">
436
+ <v-btn v-if="sortedByYear" class="bg-office" @click="sortByTitle" icon="$down"></v-btn>
437
+ TITEL
438
+ </v-col>
439
+ <v-col cols="1">
440
+ <v-btn v-if="!sortedByYear" class="bg-office" @click="sortByYear" icon="$down"></v-btn>
441
+ JAHR
442
+ </v-col>
415
443
  <v-col cols="1">RATING</v-col>
416
444
  <v-col cols="2">STATUS</v-col>
417
445
  <v-col v-if="currentAuthor.id" cols="2">