diff --git a/src/app/main/content/apps/contacts/contact-form/contact-form.component.html b/src/app/main/content/apps/contacts/contact-form/contact-form.component.html
new file mode 100644
index 00000000..c67943d2
--- /dev/null
+++ b/src/app/main/content/apps/contacts/contact-form/contact-form.component.html
@@ -0,0 +1,218 @@
+
+
+ {{dialogTitle}}
+
+
+
+
+
+ {{contact.name}}
+
+
+
+
+
diff --git a/src/app/main/content/apps/contacts/contact-form/contact-form.component.scss b/src/app/main/content/apps/contacts/contact-form/contact-form.component.scss
new file mode 100644
index 00000000..45f889e5
--- /dev/null
+++ b/src/app/main/content/apps/contacts/contact-form/contact-form.component.scss
@@ -0,0 +1,16 @@
+.contact-form-dialog {
+ .mat-dialog-container {
+ padding: 0;
+ max-width: 400px;
+ width: 400px;
+
+ .toolbar-bottom {
+ height: 200px;
+ }
+ }
+}
+
+:host {
+ display: flex;
+ flex-direction: column;
+}
diff --git a/src/app/main/content/apps/contacts/contact-form/contact-form.component.ts b/src/app/main/content/apps/contacts/contact-form/contact-form.component.ts
new file mode 100644
index 00000000..1cf2c453
--- /dev/null
+++ b/src/app/main/content/apps/contacts/contact-form/contact-form.component.ts
@@ -0,0 +1,67 @@
+import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
+import { MD_DIALOG_DATA, MdDialogRef } from '@angular/material';
+import { CalendarEvent } from 'angular-calendar';
+import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
+import 'rxjs/Rx';
+import { Contact } from '../contact.model';
+
+@Component({
+ selector : 'fuse-contacts-contact-form-dialog',
+ templateUrl : './contact-form.component.html',
+ styleUrls : ['./contact-form.component.scss'],
+ encapsulation: ViewEncapsulation.None
+})
+
+export class ContactFormDialogComponent implements OnInit
+{
+ event: CalendarEvent;
+ dialogTitle: string;
+ contactForm: FormGroup;
+ action: string;
+ contact: Contact;
+
+ constructor(
+ public dialogRef: MdDialogRef,
+ @Inject(MD_DIALOG_DATA) private data: any,
+ private formBuilder: FormBuilder
+ )
+ {
+ this.contact = data.contact;
+ this.action = data.action;
+
+ if ( this.action === 'edit' )
+ {
+ this.dialogTitle = 'Edit Contact';
+ }
+ else
+ {
+ this.dialogTitle = 'New Contact';
+ this.contact = new Contact({});
+ }
+
+ // this.contactForm = this.createContactForm();
+ }
+
+ ngOnInit()
+ {
+ }
+
+ createContactForm()
+ {
+ return new FormGroup({
+ title : new FormControl(this.event.title),
+ start : new FormControl(this.event.start),
+ end : new FormControl(this.event.end),
+ allDay: new FormControl(this.event.allDay),
+ color : this.formBuilder.group({
+ primary : new FormControl(this.event.color.primary),
+ secondary: new FormControl(this.event.color.secondary)
+ }),
+ meta :
+ this.formBuilder.group({
+ location: new FormControl(this.event.meta.location),
+ notes : new FormControl(this.event.meta.notes)
+ })
+ });
+ }
+}
diff --git a/src/app/main/content/apps/contacts/contact-list/contact-list.component.html b/src/app/main/content/apps/contacts/contact-list/contact-list.component.html
index e81b93a4..538469f8 100644
--- a/src/app/main/content/apps/contacts/contact-list/contact-list.component.html
+++ b/src/app/main/content/apps/contacts/contact-list/contact-list.component.html
@@ -94,9 +94,9 @@
-
diff --git a/src/app/main/content/apps/contacts/contact-list/contact-list.component.ts b/src/app/main/content/apps/contacts/contact-list/contact-list.component.ts
index 0399a062..12747e39 100644
--- a/src/app/main/content/apps/contacts/contact-list/contact-list.component.ts
+++ b/src/app/main/content/apps/contacts/contact-list/contact-list.component.ts
@@ -1,7 +1,10 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { ContactsService } from '../contacts.service';
import { DataSource } from '@angular/cdk';
import { Observable } from 'rxjs/Observable';
+import { ContactFormDialogComponent } from '../contact-form/contact-form.component';
+import { MdDialog, MdDialogRef } from '@angular/material';
+import { FuseConfirmDialogComponent } from '../../../../../core/components/confirm-dialog/confirm-dialog.component';
@Component({
selector : 'fuse-contacts-contact-list',
@@ -10,6 +13,8 @@ import { Observable } from 'rxjs/Observable';
})
export class ContactListComponent implements OnInit
{
+ @ViewChild('dialogContent') dialogContent: TemplateRef;
+
contacts: any;
user: any;
dataSource: FilesDataSource | null;
@@ -17,7 +22,14 @@ export class ContactListComponent implements OnInit
selectedContacts: any[];
checkboxes: {};
- constructor(private contactsService: ContactsService)
+ dialogRef: any;
+
+ confirmDialogRef: MdDialogRef;
+
+ constructor(
+ private contactsService: ContactsService,
+ public dialog: MdDialog
+ )
{
this.contactsService.onContactsChanged.subscribe(contacts => {
@@ -48,9 +60,47 @@ export class ContactListComponent implements OnInit
this.dataSource = new FilesDataSource(this.contactsService);
}
- onSelect(selected)
+ editContact(contact)
{
// this.fileManagerService.onContactSelected.next(selected);
+
+ this.dialogRef = this.dialog.open(ContactFormDialogComponent, {
+ panelClass: 'contact-form-dialog',
+ data : {
+ contact: contact,
+ action : 'edit'
+ }
+ });
+
+ /* this.dialogRef.afterClosed()
+ .subscribe(response => {
+ if ( !response )
+ {
+ return;
+ }
+ const actionType: string = response[0];
+ const formData: FormGroup = response[1];
+ switch ( actionType )
+ {
+ /!**
+ * Save
+ *!/
+ case 'save':
+
+ this.events[eventIndex] = Object.assign(this.events[eventIndex], formData.getRawValue());
+ this.refresh.next(true);
+
+ break;
+ /!**
+ * Delete
+ *!/
+ case 'delete':
+
+ this.deleteEvent(event);
+
+ break;
+ }
+ });*/
}
onSelectedChange(contactId)
diff --git a/src/app/main/content/apps/contacts/contacts.module.ts b/src/app/main/content/apps/contacts/contacts.module.ts
index 85ba07cb..fbad970e 100644
--- a/src/app/main/content/apps/contacts/contacts.module.ts
+++ b/src/app/main/content/apps/contacts/contacts.module.ts
@@ -6,6 +6,7 @@ import { ContactsComponent } from './contacts.component';
import { ContactsService } from './contacts.service';
import { ContactListComponent } from './contact-list/contact-list.component';
import { SelectedBarComponent } from './selected-bar/selected-bar.component';
+import { ContactFormDialogComponent } from './contact-form/contact-form.component';
const routes: Routes = [
{
@@ -19,19 +20,21 @@ const routes: Routes = [
];
@NgModule({
- imports : [
+ imports : [
SharedModule,
RouterModule.forChild(routes)
],
- declarations: [
+ declarations : [
ContactsComponent,
ContactListComponent,
SelectedBarComponent,
- MainSidenavComponent
+ MainSidenavComponent,
+ ContactFormDialogComponent
],
- providers : [
+ providers : [
ContactsService
- ]
+ ],
+ entryComponents: [ContactFormDialogComponent]
})
export class FuseContactsModule
{
diff --git a/src/app/main/content/apps/contacts/contacts.service.ts b/src/app/main/content/apps/contacts/contacts.service.ts
index 6b6ed458..fb5b05cf 100644
--- a/src/app/main/content/apps/contacts/contacts.service.ts
+++ b/src/app/main/content/apps/contacts/contacts.service.ts
@@ -18,10 +18,15 @@ export class ContactsService implements Resolve
onSearchTextChanged: Subject = new Subject();
+ onFilterChanged: Subject = new Subject();
+
contacts: Contact[];
user: any;
selectedContacts: string[] = [];
+ searchText: string;
+ filterBy: string;
+
constructor(private http: Http)
{
}
@@ -44,7 +49,13 @@ export class ContactsService implements Resolve
([files]) => {
this.onSearchTextChanged.subscribe(searchText => {
- this.getContacts(searchText);
+ this.searchText = searchText;
+ this.getContacts();
+ });
+
+ this.onFilterChanged.subscribe(filter => {
+ this.filterBy = filter;
+ this.getContacts();
});
resolve();
@@ -55,7 +66,7 @@ export class ContactsService implements Resolve
});
}
- getContacts(searchText?): Promise
+ getContacts(): Promise
{
return new Promise((resolve, reject) => {
this.http.get('api/contacts-contacts')
@@ -63,9 +74,23 @@ export class ContactsService implements Resolve
this.contacts = response.json().data;
- if ( searchText && searchText !== '' )
+ if ( this.filterBy === 'starred' )
{
- this.contacts = FuseUtils.filterArrayByString(this.contacts, searchText);
+ this.contacts = this.contacts.filter(_contact => {
+ return this.user.starred.includes(_contact.id);
+ });
+ }
+
+ if ( this.filterBy === 'frequent' )
+ {
+ this.contacts = this.contacts.filter(_contact => {
+ return this.user.frequentContacts.includes(_contact.id);
+ });
+ }
+
+ if ( this.searchText && this.searchText !== '' )
+ {
+ this.contacts = FuseUtils.filterArrayByString(this.contacts, this.searchText);
}
this.contacts = this.contacts.map(contact => {
@@ -180,6 +205,7 @@ export class ContactsService implements Resolve
this.http.post('api/contacts-user/' + this.user.id, {...userData})
.subscribe(response => {
this.getUserData();
+ this.getContacts();
resolve(response);
});
});
diff --git a/src/app/main/content/apps/contacts/sidenavs/main/main.component.html b/src/app/main/content/apps/contacts/sidenavs/main/main.component.html
index c6c5d63d..637f20e7 100644
--- a/src/app/main/content/apps/contacts/sidenavs/main/main.component.html
+++ b/src/app/main/content/apps/contacts/sidenavs/main/main.component.html
@@ -18,19 +18,19 @@