mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-02-02 06:52:42 +00:00
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
/*
|
|
* Copyright (C) 2022 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 {Component, Input, OnInit, ViewChild} from '@angular/core';
|
|
import {IonReorderGroup, ModalController} from '@ionic/angular';
|
|
import {ItemReorderEventDetail} from '@ionic/core';
|
|
import {SCThings} from '@openstapps/core';
|
|
import {MenuItemInterface} from '../sections/navigation-section/menu-item.interface';
|
|
import {EditModalTypeEnum} from './edit-modal-type.enum';
|
|
|
|
/**
|
|
* Shows a modal window to sort and enable/disable menu items
|
|
*/
|
|
@Component({
|
|
selector: 'stapps-edit-modal',
|
|
templateUrl: 'edit-modal.component.html',
|
|
styleUrls: ['edit-modal.component.scss'],
|
|
})
|
|
export class EditModalComponent implements OnInit {
|
|
@ViewChild(IonReorderGroup) reorderGroup: IonReorderGroup;
|
|
|
|
@Input() type: EditModalTypeEnum = EditModalTypeEnum.CHECKBOXES;
|
|
|
|
@Input() items: MenuItemInterface[] | SCThings[];
|
|
|
|
@Input() selectedValue: string;
|
|
|
|
reorderedItems: MenuItemInterface[] | SCThings[];
|
|
|
|
types = EditModalTypeEnum;
|
|
|
|
constructor(public modalController: ModalController) {}
|
|
|
|
ngOnInit() {
|
|
this.reorderedItems = this.items;
|
|
}
|
|
|
|
ionViewWillLeave() {
|
|
this.dismissModal();
|
|
}
|
|
|
|
doReorder(event: CustomEvent<ItemReorderEventDetail>) {
|
|
this.reorderedItems = event.detail.complete(this.reorderedItems);
|
|
}
|
|
|
|
onSaveClick() {
|
|
this.modalController.dismiss({
|
|
items: this.reorderedItems,
|
|
selectedValue: this.selectedValue,
|
|
});
|
|
}
|
|
|
|
dismissModal() {
|
|
this.modalController.dismiss();
|
|
}
|
|
}
|