Skip to content

Commit

Permalink
NOBUG: misc cleanup before further dev
Browse files Browse the repository at this point in the history
  • Loading branch information
severinbeauvais committed Mar 23, 2018
1 parent 4e0dbde commit 697ae9c
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 119 deletions.
81 changes: 40 additions & 41 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,43 @@
// https://karma-runner.github.io/0.13/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false
});
};

config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
files: [
{ pattern: './src/test.ts', watched: false }
],
preprocessors: {
'./src/test.ts': ['@angular/cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
coverageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
"tslint": "4.5.0",
"typescript": "<2.4.0"
}
}
}
4 changes: 2 additions & 2 deletions protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ exports.config = {
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
print: function () { }
},
beforeLaunch: function() {
beforeLaunch: function () {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { DialogComponent, DialogService } from 'ng2-bootstrap-modal';

import { User } from 'app/models/user';
Expand All @@ -15,7 +15,9 @@ export interface DataModel {
styleUrls: ['./add-edit-user.component.scss']
})

export class AddEditUserComponent extends DialogComponent<DataModel, boolean> implements DataModel {
// NOTE: dialog components must not implement OnDestroy
// otherwise they don't return a result
export class AddEditUserComponent extends DialogComponent<DataModel, boolean> implements DataModel, OnInit {
title: string;
message: string;
model: User;
Expand All @@ -29,7 +31,6 @@ export class AddEditUserComponent extends DialogComponent<DataModel, boolean> im
super(dialogService);
}

// tslint:disable-next-line:use-life-cycle-interface
ngOnInit() {
// console.log("this.model:", this.user);
// TODO: Current is simple method of assigning roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as moment from 'moment-timezone';
import * as _ from 'lodash';

import { Constants } from 'app/utils/constants';
import { SelectOrganizationComponent } from '../select-organization/select-organization.component';
import { SelectOrganizationComponent } from 'app/applications/select-organization/select-organization.component';
import { ConfirmComponent } from 'app/confirm/confirm.component';
import { Application } from 'app/models/application';
import { Document } from 'app/models/document';
Expand Down Expand Up @@ -187,11 +187,16 @@ export class ApplicationAddEditComponent implements OnInit, OnDestroy {
backdropColor: 'rgba(0, 0, 0, 0.5)'
})
.takeUntil(this.ngUnsubscribe)
.subscribe((clientString: string) => {
if (clientString) {
self.application.client = clientString;
.subscribe(
clientString => {
if (clientString && clientString.length > 0) {
self.application.client = clientString;
}
},
error => {
console.log('error =', error);
}
});
);
}

saveApplication() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,57 +1,35 @@
import { Component, OnInit } from '@angular/core';
import { DialogComponent, DialogService } from 'ng2-bootstrap-modal';
import { Router, ActivatedRoute } from '@angular/router';
import { OrganizationService } from 'app/services/organization.service';
import * as _ from 'lodash';

import { SearchService } from 'app/services/search.service';
import { Organization } from 'app/models/organization';
import { Client } from 'app/models/client';
import * as _ from 'lodash';

export interface DataModel {
dispositionId: number;
interestedPartyId: number;
}

@Component({
selector: 'app-select-organization',
templateUrl: './select-organization.component.html',
styleUrls: ['./select-organization.component.scss']
})

// NOTE: dialog components must not implement OnDestroy
// otherwise they don't return a result
export class SelectOrganizationComponent extends DialogComponent<DataModel, string> implements DataModel, OnInit {
public dispositionId: number;
public interestedPartyId: number;
public clients: Client[] = [];
public selectedClients: string[];
public dispositionId: number = null;
public clients: Array<Client> = [];
public selectedClients: Array<Client> = [];
public page = 1;
public selectedOrg: Organization = null;

constructor(
public dialogService: DialogService,
private router: Router,
private orgService: OrganizationService,
private searchService: SearchService
) {
super(dialogService);
this.selectedClients = [];
}

toggleClient(client) {
if (this.isClientSelected(client)) {
_.remove(this.selectedClients, client);
} else {
this.selectedClients.push(client);
}
}

isClientSelected(client) {
const foundClient = _.find(this.selectedClients, function (c) {
return (c === client);
});
if (foundClient) {
return true;
} else {
return false;
}
}

ngOnInit() {
Expand All @@ -61,19 +39,35 @@ export class SelectOrganizationComponent extends DialogComponent<DataModel, stri
data => {
_.each(data, function (i) {
self.clients.push(new Client(i));
// Pre-select the existing org if it's in the list
// Pre-select the existing clients if they're in the list
// if (i._id === self.dispositionId) {
// self.selectedOrg = i;
// self.selectedClients = i;
// }
});
},
error => {
// if 403, redir to login page
if (error.startsWith('403')) { this.router.navigate(['/login']); }
alert('Error loading users');
alert('Error loading clients');
});
}

toggleClient(client: Client) {
if (this.isClientSelected(client)) {
_.remove(this.selectedClients, client);
} else {
this.selectedClients.push(client);
}
}

isClientSelected(client: Client): boolean {
// TODO: this should be debounced as it's called a lot! (mouse over clickable row to see this)
const foundClient = _.find(this.selectedClients, function (c) {
return (c === client);
});
return foundClient ? true : false;
}

save() {
let res = '';
_.each(this.selectedClients, function (client) {
Expand All @@ -88,9 +82,8 @@ export class SelectOrganizationComponent extends DialogComponent<DataModel, stri
res += c.INDIVIDUALS_LAST_NAME + ', ';
}
});
// trim the last comma
this.result = res.replace(/,\s*$/, '');
// console.log(this.result);
// alert('Save is not yet implemented');
this.close();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { NgbDateParserFormatter, NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import { DialogComponent, DialogService } from 'ng2-bootstrap-modal';
import * as moment from 'moment';
Expand All @@ -19,7 +19,9 @@ export interface DataModel {
styleUrls: ['./add-edit-comment-period.component.scss']
})

export class AddEditCommentPeriodComponent extends DialogComponent<DataModel, boolean> implements DataModel {
// NOTE: dialog components must not implement OnDestroy
// otherwise they don't return a result
export class AddEditCommentPeriodComponent extends DialogComponent<DataModel, boolean> implements DataModel, OnInit {
public title: string;
public message: string;
public commentPeriod: CommentPeriod;
Expand All @@ -38,20 +40,17 @@ export class AddEditCommentPeriodComponent extends DialogComponent<DataModel, bo
super(dialogService);
}

// tslint:disable-next-line:use-life-cycle-interface
ngOnInit() {
if (!this.commentPeriod) {
this.isNew = true;
// create new comment period
this.cp = new CommentPeriod();
this.cp._application = this.appId;


// set initial start date and duration
const n = new Date();
this.onDate1Chg({ 'year': n.getFullYear(), 'month': n.getMonth() + 1, 'day': n.getDate() });
this.onDeltaChg(this.delta);

} else {
this.isNew = false;
// make a **deep copy** of the passed-in comment period so we don't change it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class ManageCommentPeriodsComponent implements OnInit, OnDestroy {
backdropColor: 'rgba(0, 0, 0, 0.5)'
})
.takeUntil(this.ngUnsubscribe)
.subscribe((result: boolean) => {
.subscribe(result => {
if (result) {
// HACK: refresh UI because template item isn't being refreshed otherwise
this.refreshUI();
Expand All @@ -137,7 +137,7 @@ export class ManageCommentPeriodsComponent implements OnInit, OnDestroy {
backdropColor: 'rgba(0, 0, 0, 0.5)'
})
.takeUntil(this.ngUnsubscribe)
.subscribe((result: boolean) => {
.subscribe(result => {
if (result) {
// HACK: refresh UI because template item isn't being refreshed otherwise
this.refreshUI();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap';
import { DialogComponent, DialogService } from 'ng2-bootstrap-modal';

Expand All @@ -16,7 +16,9 @@ export interface DataModel {
styleUrls: ['./add-comment.component.scss']
})

export class AddCommentComponent extends DialogComponent<DataModel, boolean> implements DataModel {
// NOTE: dialog components must not implement OnDestroy
// otherwise they don't return a result
export class AddCommentComponent extends DialogComponent<DataModel, boolean> implements DataModel, OnInit {
public title: string;
public message: string;
public periodId: string;
Expand All @@ -33,7 +35,6 @@ export class AddCommentComponent extends DialogComponent<DataModel, boolean> imp
this.showAlert = false;
}

// tslint:disable-next-line:use-life-cycle-interface
ngOnInit() {
console.log('period id=', this.periodId);
}
Expand Down
Loading

0 comments on commit 697ae9c

Please sign in to comment.