mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 00:23:03 +00:00
refactor: update openstapps packages
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/*
|
||||
* Copyright (C) 2021 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
@@ -13,6 +12,8 @@
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
@@ -225,9 +226,9 @@ export class AddEventPopoverComponent implements OnInit, OnDestroy {
|
||||
selected: this.uuids.includes(item.uid),
|
||||
item: item,
|
||||
})),
|
||||
it => it.item.frequency,
|
||||
it => it.item.repeatFrequency,
|
||||
),
|
||||
it => it.item.frequency,
|
||||
it => it.item.repeatFrequency,
|
||||
),
|
||||
).map(item => new TreeNode(item, this.ref)),
|
||||
this.ref,
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
<!--
|
||||
~ Copyright (C) 2021 StApps
|
||||
~ This program is free software: you can redistribute it and/or modify it
|
||||
~ under the terms of the GNU General Public License as published by the Free
|
||||
~ Software Foundation, version 3.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
~ more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License along with
|
||||
~ this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<ion-card-content>
|
||||
<ion-item-group>
|
||||
<ion-item-divider (click)="selection.click()">
|
||||
@@ -14,7 +29,9 @@
|
||||
<ion-item-group *ngFor="let frequency of selection.children">
|
||||
<ion-item-divider (click)="frequency.click()">
|
||||
<ion-label>{{
|
||||
'frequency' | thingTranslate: frequency.children[0].item | titlecase
|
||||
frequency.children[0].item.repeatFrequency
|
||||
? (frequency.children[0].item.repeatFrequency | amDuration)
|
||||
: ('data.chips.add_events.popover.SINGLE' | translate | titlecase)
|
||||
}}</ion-label>
|
||||
<ion-checkbox
|
||||
slot="start"
|
||||
|
||||
@@ -42,8 +42,10 @@ export class DataIconPipe implements PipeTransform {
|
||||
'floor': 'caret-up-circle',
|
||||
'message': 'newspaper',
|
||||
'organization': 'briefcase',
|
||||
'periodical': 'newspaper',
|
||||
'person': 'person',
|
||||
'point of interest': 'location',
|
||||
'publication event': 'megaphone',
|
||||
'room': 'location',
|
||||
'semester': 'school',
|
||||
'setting': 'settings',
|
||||
|
||||
@@ -23,9 +23,7 @@ import {
|
||||
SCSearchQuery,
|
||||
SCSearchResponse,
|
||||
SCSearchValueFilter,
|
||||
SCThing,
|
||||
SCThingOriginType,
|
||||
SCThings,
|
||||
SCThingType,
|
||||
} from '@openstapps/core';
|
||||
import {sampleThingsMap} from '../../_helpers/data/sample-things';
|
||||
@@ -66,7 +64,7 @@ describe('DataProvider', () => {
|
||||
filter: sampleFilter,
|
||||
};
|
||||
|
||||
const sampleSavable: SCSaveableThing<SCThings> = {
|
||||
const sampleSavable: SCSaveableThing = {
|
||||
data: sampleThing,
|
||||
name: sampleThing.name,
|
||||
origin: {
|
||||
@@ -168,7 +166,7 @@ describe('DataProvider', () => {
|
||||
});
|
||||
|
||||
it('should put an data item into the local database (storage)', async () => {
|
||||
let providedThing: SCSaveableThing<SCThing>;
|
||||
let providedThing: SCSaveableThing;
|
||||
spyOn(storageProvider, 'put' as any).and.callFake(
|
||||
(_id: any, thing: any) => {
|
||||
providedThing = thing;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Client} from '@openstapps/api/lib/client';
|
||||
import {
|
||||
SCIndexableThings,
|
||||
SCMultiSearchRequest,
|
||||
SCMultiSearchResponse,
|
||||
SCSearchRequest,
|
||||
@@ -148,23 +149,18 @@ export class DataProvider {
|
||||
/**
|
||||
* Provides a savable thing from the local database using the provided UID
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
scope: DataScope.Local,
|
||||
): Promise<SCSaveableThing<SCThings>>;
|
||||
async get(uid: string, scope: DataScope.Local): Promise<SCSaveableThing>;
|
||||
/**
|
||||
* Provides a thing from the backend
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
scope: DataScope.Remote,
|
||||
): Promise<SCThings | SCSaveableThing<SCThings>>;
|
||||
): Promise<SCThings | SCSaveableThing>;
|
||||
/**
|
||||
* Provides a thing from both local database and backend
|
||||
*/
|
||||
async get(
|
||||
uid: string,
|
||||
): Promise<Map<DataScope, SCThings | SCSaveableThing<SCThings>>>;
|
||||
async get(uid: string): Promise<Map<DataScope, SCThings | SCSaveableThing>>;
|
||||
|
||||
/**
|
||||
* Provides a thing from the local database only, backend only or both, depending on the scope
|
||||
@@ -176,19 +172,15 @@ export class DataProvider {
|
||||
uid: string,
|
||||
scope?: DataScope,
|
||||
): Promise<
|
||||
| SCThings
|
||||
| SCSaveableThing<SCThings>
|
||||
| Map<DataScope, SCThings | SCSaveableThing<SCThings>>
|
||||
SCThings | SCSaveableThing | Map<DataScope, SCThings | SCSaveableThing>
|
||||
> {
|
||||
if (scope === DataScope.Local) {
|
||||
return this.storageProvider.get<SCSaveableThing<SCThings>>(
|
||||
this.getDataKey(uid),
|
||||
);
|
||||
return this.storageProvider.get<SCSaveableThing>(this.getDataKey(uid));
|
||||
}
|
||||
if (scope === DataScope.Remote) {
|
||||
return this.client.getThing(uid);
|
||||
}
|
||||
const map: Map<DataScope, SCThings | SCSaveableThing<SCThings>> = new Map();
|
||||
const map: Map<DataScope, SCThings | SCSaveableThing> = new Map();
|
||||
map.set(DataScope.Local, await this.get(uid, DataScope.Local));
|
||||
map.set(DataScope.Remote, await this.get(uid, DataScope.Remote));
|
||||
|
||||
@@ -198,10 +190,8 @@ export class DataProvider {
|
||||
/**
|
||||
* Provides all things saved in the local database
|
||||
*/
|
||||
async getAll(): Promise<Map<string, SCSaveableThing<SCThings>>> {
|
||||
return this.storageProvider.search<SCSaveableThing<SCThings>>(
|
||||
this.storagePrefix,
|
||||
);
|
||||
async getAll(): Promise<Map<string, SCSaveableThing>> {
|
||||
return this.storageProvider.search<SCSaveableThing>(this.storagePrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,10 +238,10 @@ export class DataProvider {
|
||||
* @param [type] Savable type (e.g. 'favorite'); if nothing is provided then type of the thing is used
|
||||
*/
|
||||
async put(
|
||||
item: SCThings,
|
||||
item: SCIndexableThings,
|
||||
type?: SCThingType,
|
||||
): Promise<SCSaveableThing<SCThings>> {
|
||||
const savableItem: SCSaveableThing<SCThings> = {
|
||||
): Promise<SCSaveableThing> {
|
||||
const savableItem: SCSaveableThing = {
|
||||
data: item,
|
||||
name: item.name,
|
||||
origin: {
|
||||
@@ -263,7 +253,7 @@ export class DataProvider {
|
||||
};
|
||||
|
||||
// @TODO: Implementation for saving item into the backend (user's account)
|
||||
return this.storageProvider.put<SCSaveableThing<SCThings>>(
|
||||
return this.storageProvider.put<SCSaveableThing>(
|
||||
this.getDataKey(item.uid),
|
||||
savableItem,
|
||||
);
|
||||
|
||||
@@ -50,9 +50,9 @@ export class DataDetailComponent implements OnInit {
|
||||
* Type guard for SCSavableThing
|
||||
*/
|
||||
static isSCSavableThing(
|
||||
thing: SCThings | SCSaveableThing<SCThings>,
|
||||
): thing is SCSaveableThing<SCThings> {
|
||||
return typeof (thing as SCSaveableThing<SCThings>).data !== 'undefined';
|
||||
thing: SCThings | SCSaveableThing,
|
||||
): thing is SCSaveableThing {
|
||||
return typeof (thing as SCSaveableThing).data !== 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
<p>
|
||||
<ion-icon name="calendar"></ion-icon>
|
||||
<span>
|
||||
{{ item.frequency }}, {{ item.dates[0] | amDateFormat: 'dddd' }}
|
||||
{{ item.repeatFrequency | amDuration }},
|
||||
{{ item.dates[0] | amDateFormat: 'dddd' }}
|
||||
<span
|
||||
>({{ item.dates[0] | amDateFormat: 'll' }} -
|
||||
{{
|
||||
|
||||
Reference in New Issue
Block a user