refactor: use SwiperJS in schedule module

This commit is contained in:
Wieland Schöbl
2021-11-09 17:12:45 +00:00
parent d6cb7e1d3b
commit 523e34f6e4
27 changed files with 771 additions and 421 deletions

View File

@@ -0,0 +1,27 @@
/*
* 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/>.
*/
import {Pipe, PipeTransform} from '@angular/core';
import {Moment} from 'moment';
@Pipe({
name: 'dateFromIndex',
pure: true,
})
export class DateFromIndexPipe implements PipeTransform {
transform(index: number, baseline: Moment): Moment {
return baseline.clone().add(index, 'days');
}
}

View File

@@ -30,7 +30,16 @@ export class DateIsThisPipe implements PipeTransform {
* Transform
*/
// tslint:disable-next-line:prefer-function-over-method
transform(value: Moment, granularity: unitOfTime.StartOf): boolean {
return value.isSame(moment(moment.now()), granularity);
transform(
value: Moment | string | number,
granularity: unitOfTime.StartOf,
): boolean {
return (
typeof value === 'string'
? moment(value)
: typeof value === 'number'
? moment.unix(value)
: value
).isSame(moment(moment.now()), granularity);
}
}

View File

@@ -17,9 +17,20 @@ import {NgModule} from '@angular/core';
import {ArrayLastPipe} from './array-last.pipe';
import {DateIsThisPipe} from './date-is-today.pipe';
import {NullishCoalescingPipe} from './nullish-coalecing.pipe';
import {DateFromIndexPipe} from './date-from-index.pipe';
@NgModule({
declarations: [ArrayLastPipe, DateIsThisPipe, NullishCoalescingPipe],
exports: [ArrayLastPipe, DateIsThisPipe, NullishCoalescingPipe],
declarations: [
ArrayLastPipe,
DateIsThisPipe,
NullishCoalescingPipe,
DateFromIndexPipe,
],
exports: [
ArrayLastPipe,
DateIsThisPipe,
NullishCoalescingPipe,
DateFromIndexPipe,
],
})
export class UtilModule {}