Skip to content

Commit

Permalink
Merge pull request #287 from severinbeauvais/PRC-753
Browse files Browse the repository at this point in the history
PRC-753: replaced file upload control with custom component + cleanup
  • Loading branch information
marklise authored Oct 30, 2018
2 parents 301ec6a + 4519b07 commit b72f76c
Show file tree
Hide file tree
Showing 31 changed files with 146 additions and 500 deletions.
1 change: 0 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { LoginComponent } from './login/login.component';
import { SearchComponent } from './search/search.component';
import { AdministrationComponent } from './administration/administration.component';
import { UsersComponent } from './administration/users/users.component';
import { HomeComponent } from './home/home.component';

import { CanDeactivateGuard } from 'app/services/can-deactivate-guard.service';

Expand Down
29 changes: 14 additions & 15 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
// external imports
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgxPaginationModule } from 'ngx-pagination';
import { Ng2PageScrollModule } from 'ng2-page-scroll';
import { BootstrapModalModule } from 'ng2-bootstrap-modal';
import { CookieService } from 'ngx-cookie-service';

import { AppRoutingModule } from 'app/app-routing.module';
// modules
import { SharedModule } from 'app/shared.module';
import { ApplicationsModule } from 'app/applications/applications.module';
import { AppRoutingModule } from 'app/app-routing.module';

// components
import { AppComponent } from 'app/app.component';
import { HomeComponent } from 'app/home/home.component';
import { SearchComponent } from 'app/search/search.component';
import { LoginComponent } from 'app/login/login.component';
import { ConfirmComponent } from 'app/confirm/confirm.component';
import { HeaderComponent } from 'app/header/header.component';
import { FooterComponent } from 'app/footer/footer.component';
import { AdministrationComponent } from 'app/administration/administration.component';
import { UsersComponent } from 'app/administration/users/users.component';
import { AddEditUserComponent } from 'app/administration/users/add-edit-user/add-edit-user.component';
import { SelectOrganizationComponent } from 'app/select-organization/select-organization.component';

// services
import { SearchService } from 'app/services/search.service';
Expand All @@ -33,16 +42,6 @@ import { UserService } from 'app/services/user.service';
import { CanDeactivateGuard } from 'app/services/can-deactivate-guard.service';
import { ConfigService } from 'app/services/config.service';

// feature modules
import { ApplicationsModule } from 'app/applications/applications.module';
import { CommentingModule } from 'app/commenting/commenting.module';
import { HeaderComponent } from 'app/header/header.component';
import { FooterComponent } from 'app/footer/footer.component';
import { AdministrationComponent } from 'app/administration/administration.component';
import { UsersComponent } from 'app/administration/users/users.component';
import { AddEditUserComponent } from 'app/administration/users/add-edit-user/add-edit-user.component';
import { SelectOrganizationComponent } from 'app/applications/select-organization/select-organization.component';

@NgModule({
declarations: [
AppComponent,
Expand All @@ -58,13 +57,12 @@ import { SelectOrganizationComponent } from 'app/applications/select-organizatio
SelectOrganizationComponent
],
imports: [
BrowserAnimationsModule,
BrowserModule,
BrowserAnimationsModule,
FormsModule,
HttpModule,
SharedModule,
ApplicationsModule,
CommentingModule,
AppRoutingModule, // <-- module import order matters - https://angular.io/guide/router#module-import-order-matters
NgbModule.forRoot(),
NgxPaginationModule,
Expand All @@ -88,7 +86,8 @@ import { SelectOrganizationComponent } from 'app/applications/select-organizatio
],
entryComponents: [
ConfirmComponent,
AddEditUserComponent
AddEditUserComponent,
SelectOrganizationComponent
],
bootstrap: [AppComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,8 @@ <h1><span class="text-muted">Crown land File: {{application['clFile']}} &nbsp;&r
</span>
</li>
</ul>
<div class="file-upload">
<input type="file" name="fileInput1" size="5000000" multiple #fileInput1
(change)="addDocuments($event.target.files, application.documents);fileInput1.value=null">
<div class="file-upload__target">
<span class="file-upload__prompt">
<i class="file-upload__prompt-icon material-icons">file_upload</i>
<span class="file-upload__prompt-msg">Drop files to attach, or <strong>browse</strong>.</span>
</span>
</div>
</div>
<app-file-upload [maxFiles]="0" [showInfo]="false" [showList]="false" [files]="applicationFiles"
(filesChange)="addDocuments($event, application.documents); applicationFiles = []"></app-file-upload>
</div>
</fieldset>

Expand Down Expand Up @@ -190,16 +182,8 @@ <h1><span class="text-muted">Crown land File: {{application['clFile']}} &nbsp;&r
</span>
</li>
</ul>
<div class="file-upload">
<input type="file" name="fileInput2" size="5000000" multiple #fileInput2
(change)="addDocuments($event.target.files, application.decision.documents);fileInput2.value=null">
<div class="file-upload__target">
<span class="file-upload__prompt">
<i class="file-upload__prompt-icon material-icons">file_upload</i>
<span class="file-upload__prompt-msg">Drop files to attach, or <em>browse</em>.</span>
</span>
</div>
</div>
<app-file-upload [maxFiles]="0" [showInfo]="false" [showList]="false" [files]="decisionFiles"
(filesChange)="addDocuments($event, application.decision.documents); decisionFiles = []"></app-file-upload>
</div>
</div>
<button class="btn content-btn-alt" type="button" title="Add a decision"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'rxjs/add/operator/concat';
import * as moment from 'moment-timezone';
import * as _ from 'lodash';

import { SelectOrganizationComponent } from 'app/applications/select-organization/select-organization.component';
import { SelectOrganizationComponent } from 'app/select-organization/select-organization.component';
import { ConfirmComponent } from 'app/confirm/confirm.component';
import { Application } from 'app/models/application';
import { CommentPeriod } from 'app/models/commentperiod';
Expand Down Expand Up @@ -46,6 +46,8 @@ export class ApplicationAddEditComponent implements OnInit, OnDestroy {
private ngUnsubscribe: Subject<boolean> = new Subject<boolean>();
private docsToDelete: Document[] = [];
private decisionToDelete: Decision = null;
public applicationFiles: Array<File> = [];
public decisionFiles: Array<File> = [];

constructor(
private route: ActivatedRoute,
Expand Down
8 changes: 8 additions & 0 deletions src/app/applications/applications-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ApplicationListComponent } from './application-list/application-list.co
import { ApplicationDetailComponent } from './application-detail/application-detail.component';
import { ApplicationAddEditComponent } from './application-add-edit/application-add-edit.component';
import { ApplicationDetailResolver } from './application-resolver.service';
import { ReviewCommentsComponent } from './review-comments/review-comments.component';

import { CanDeactivateGuard } from 'app/services/can-deactivate-guard.service';

Expand All @@ -27,6 +28,13 @@ const routes: Routes = [
application: ApplicationDetailResolver
},
canDeactivate: [CanDeactivateGuard]
},
{
path: 'comments/:appId',
component: ReviewCommentsComponent,
resolve: {
application: ApplicationDetailResolver
}
}
];

Expand Down
23 changes: 14 additions & 9 deletions src/app/applications/applications.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { ApplicationListComponent } from './application-list/application-list.co
import { ApplicationDetailComponent } from './application-detail/application-detail.component';
import { ApplicationAsideComponent } from './application-aside/application-aside.component';
import { ApplicationAddEditComponent } from './application-add-edit/application-add-edit.component';
import { SelectOrganizationComponent } from './select-organization/select-organization.component';
import { ReviewCommentsComponent } from './review-comments/review-comments.component';
import { CommentDetailComponent } from './review-comments/comment-detail/comment-detail.component';

// services
import { ApiService } from '../services/api';
import { ApplicationService } from '../services/application.service';
import { ApiService } from 'app/services/api';
import { ApplicationService } from 'app/services/application.service';
import { ExcelService } from 'app/services/excel.service';

@NgModule({
imports: [
Expand All @@ -31,20 +33,23 @@ import { ApplicationService } from '../services/application.service';
ApplicationListComponent,
ApplicationDetailComponent,
ApplicationAsideComponent,
ApplicationAddEditComponent
ApplicationAddEditComponent,
ReviewCommentsComponent,
CommentDetailComponent
],
exports: [
ApplicationListComponent,
ApplicationDetailComponent,
ApplicationAsideComponent,
ApplicationAddEditComponent
ApplicationAddEditComponent,
ReviewCommentsComponent,
CommentDetailComponent
],
providers: [
ApiService,
ApplicationService
],
entryComponents: [
SelectOrganizationComponent
ApplicationService,
ExcelService
]
})

export class ApplicationsModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('CommentDetailComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CommentDetailComponent ]
declarations: [CommentDetailComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ export class CommentDetailComponent implements OnChanges, OnDestroy {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('ReviewCommentsComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ReviewCommentsComponent ]
declarations: [ReviewCommentsComponent]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { CommentService } from 'app/services/comment.service';
import { ExcelService } from 'app/services/excel.service';
import { ApiService } from 'app/services/api';

import { AddCommentComponent } from './add-comment/add-comment.component';

class SortKey {
innerHTML: string;
value: string;
Expand Down Expand Up @@ -139,30 +137,6 @@ export class ReviewCommentsComponent implements OnInit, OnDestroy {
this.getData();
}

addClick() {
if (this.application.currentPeriod && this.application.currentPeriod._id) {
this.dialogService.addDialog(AddCommentComponent,
{
periodId: this.application.currentPeriod._id
}, {
// index: 0,
// autoCloseTimeout: 10000,
// closeByClickingOutside: true,
backdropColor: 'rgba(0, 0, 0, 0.5)'
})
.takeUntil(this.ngUnsubscribe)
.subscribe((isConfirmed) => {
// we get dialog result
if (isConfirmed) {
// TODO: reload page or rebind list?
console.log('saved');
} else {
console.log('canceled');
}
});
}
}

setCurrentComment(item: Comment) {
const index = _.findIndex(this.comments, { _id: item._id });
if (index >= 0) {
Expand Down
22 changes: 0 additions & 22 deletions src/app/commenting/commenting-routing.module.ts

This file was deleted.

50 changes: 0 additions & 50 deletions src/app/commenting/commenting.module.ts

This file was deleted.

Loading

0 comments on commit b72f76c

Please sign in to comment.