Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration: confirmation-modal component #148

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions src/app/common/modals/confirmation-modal/confirmation-modal.coffee

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<div class="modal-header clearfix">
<h3 class="modal-title">
<i class="fa fa-question-circle fa-2x pull-left"></i>
<div>{{title}}</div>
<div>{{ title }}</div>
<small>Please confirm that you want to perform this action.</small>
</h3>
</div>
<div class="modal-body">
{{message}}
<div class="modal-body" style="font-size: 1.5em;">
{{ message }}
</div>
<div class="modal-footer clearfix">
<div class="btn-group">
<label class="btn btn-success" ng-click="confirmAction()">
<label class="btn btn-success" (click)="confirmAction()">
<i class="fa fa-check"></i> Confirm
</label>
<label class="btn btn-danger" ng-click="cancelAction()">
<label class="btn btn-danger" (click)="cancelAction()">
<i class="fa fa-times"></i> Cancel
</label>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Component, OnInit, Input, Inject} from '@angular/core';
import { alertService } from 'src/app/ajs-upgraded-providers';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

@Component({
selector: 'confirmation-modal',
templateUrl: './confirmation-modal.component.html',
styleUrls: ['./confirmation-modal.component.scss'],
})
export class ConfirmationModalComponent implements OnInit {
@Input() title: string;
@Input() message: string;
@Input() action: () => void;

constructor(
@Inject(alertService) private alertService: any,
public dialogRef: MatDialogRef<ConfirmationModalComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
) {}

ngOnInit(): void {
console.log('confirmation-model ngOnInit()');
}

public confirmAction() {
console.log('confirmAction');
if (typeof this.action === 'function') {
this.action();
} else {
this.alertService.add("danger", `${this.title} action failed`, 3000);
}
/** note - page reload after closing **/
this.dialogRef.close();
}

public cancelAction() {
console.log('cancelAction');
this.alertService.add("info", `${this.title} action cancelled`, 3000);
this.dialogRef.close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';
import { ConfirmationModalComponent } from './confirmation-modal.component';

@Injectable({
providedIn: 'root',
})
export class ConfirmationModalService {
constructor(public dialog: MatDialog) {}

public show(title: string, message: string, action?: any) {
let dialogRef: MatDialogRef<ConfirmationModalComponent, any>;
dialogRef = this.dialog.open(ConfirmationModalComponent, {position: {top: '2.5%'}});
dialogRef.updateSize("42.5%", "");
dialogRef.componentInstance.title = title;
dialogRef.componentInstance.message = message;
dialogRef.componentInstance.action = action;
}
}
1 change: 0 additions & 1 deletion src/app/common/modals/modals.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
angular.module("doubtfire.common.modals", [
'doubtfire.common.modals.csv-result-modal'
'doubtfire.common.modals.progress-modal'
'doubtfire.common.modals.confirmation-modal'
'doubtfire.common.modals.comments-modal'
])
2 changes: 2 additions & 0 deletions src/app/doubtfire-angular.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import { ExtensionCommentComponent } from './tasks/task-comments-viewer/extensio
import { CampusListComponent } from './admin/institution-settings/campuses/campus-list/campus-list.component';
import { ExtensionModalComponent } from './common/modals/extension-modal/extension-modal.component';
import { CalendarModalComponent } from './common/modals/calendar-modal/calendar-modal.component';
import { ConfirmationModalComponent } from './common/modals/confirmation-modal/confirmation-modal.component';
import { MatRadioModule } from '@angular/material/radio';
import { MatButtonToggleModule } from '@angular/material/button-toggle';
import { MAT_DATE_LOCALE, MatOptionModule } from '@angular/material/core';
Expand Down Expand Up @@ -250,6 +251,7 @@ import { TasksViewerComponent } from './units/states/tasks/tasks-viewer/tasks-vi
OverseerImageListComponent,
ExtensionModalComponent,
CalendarModalComponent,
ConfirmationModalComponent,
InstitutionSettingsComponent,
HomeComponent,
CommentBubbleActionComponent,
Expand Down
3 changes: 2 additions & 1 deletion src/app/doubtfire-angularjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ import 'build/src/app/units/states/analytics/analytics.js';
import 'build/src/app/common/filters/filters.js';
import 'build/src/app/common/content-editable/content-editable.js';
import 'build/src/app/common/alert-list/alert-list.js';
import 'build/src/app/common/modals/confirmation-modal/confirmation-modal.js';
import 'build/src/app/common/modals/comments-modal/comments-modal.js';
import 'build/src/app/common/modals/csv-result-modal/csv-result-modal.js';
import 'build/src/app/common/modals/progress-modal/progress-modal.js';
Expand Down Expand Up @@ -174,6 +173,7 @@ import { ExtensionCommentComponent } from './tasks/task-comments-viewer/extensio
import { TaskAssessmentCommentComponent } from './tasks/task-comments-viewer/task-assessment-comment/task-assessment-comment.component';
import { ExtensionModalService } from './common/modals/extension-modal/extension-modal.service';
import { CalendarModalService } from './common/modals/calendar-modal/calendar-modal.service';
import { ConfirmationModalService } from './common/modals/confirmation-modal/confirmation-modal.service';
import { CampusListComponent } from './admin/institution-settings/campuses/campus-list/campus-list.component';
import { ActivityTypeListComponent } from './admin/institution-settings/activity-type-list/activity-type-list.component';
import { InstitutionSettingsComponent } from './admin/institution-settings/institution-settings.component';
Expand Down Expand Up @@ -264,6 +264,7 @@ DoubtfireAngularJSModule.factory(
DoubtfireAngularJSModule.factory('DoubtfireConstants', downgradeInjectable(DoubtfireConstants));
DoubtfireAngularJSModule.factory('ExtensionModal', downgradeInjectable(ExtensionModalService));
DoubtfireAngularJSModule.factory('CalendarModal', downgradeInjectable(CalendarModalService));
DoubtfireAngularJSModule.factory('ConfirmationModal', downgradeInjectable(ConfirmationModalService));
DoubtfireAngularJSModule.factory('TaskCommentService', downgradeInjectable(TaskCommentService));
DoubtfireAngularJSModule.factory('tutorialService', downgradeInjectable(TutorialService));
DoubtfireAngularJSModule.factory('streamService', downgradeInjectable(TutorialStreamService));
Expand Down
Loading