blob: a8e802e4f640c431253edb7a01ad4602c5431cda [file] [log] [blame]
Max Chu886c89f2017-08-24 15:44:27 -07001
2/*
3 * Copyright 2017-present Open Networking Foundation
4
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8
9 * http://www.apache.org/licenses/LICENSE-2.0
10
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18import {IXosConfirmConfig} from './confirm';
19
20export interface IXosConfirm {
21 open(config: IXosConfirmConfig) : void;
22 close(cb: Function) : void;
23 dismiss() : void;
24}
25
26export class XosConfirm implements IXosConfirm {
27
28 static $inject = ['$uibModal'];
29 public modalInstance;
30
31 constructor(
32 private $uibModal : any,
33 ) {
34
35 }
36
37 public open(config: IXosConfirmConfig) {
38
39 this.modalInstance = this.$uibModal.open({
40 keyboard: false,
41 component: 'xosConfirm',
42 backdrop: 'static',
43 resolve: {
44 config: () => config
45 }
46 });
47 return this.modalInstance;
48 }
49
50 public close(cb: Function) {
51 cb()
52 .then(() => {
53 this.modalInstance.close();
54 })
55 .catch((err) => {
56 this.modalInstance.dismiss(err);
57 });
58 }
59
60 public dismiss() {
61 this.modalInstance.dismiss();
62 }
63
64}
65