diff --git a/src/app/list/list.component.css b/src/app/list/list.component.css
index ef11c96..51b1d79 100644
--- a/src/app/list/list.component.css
+++ b/src/app/list/list.component.css
@@ -8,3 +8,31 @@
h2 {
border-bottom: 1px solid lightgray;
}
+
+.data-list-container {
+ display: flex;
+}
+
+.data-list {
+ width: 50%;
+ padding: 20px;
+}
+
+.card-list {
+ display: flex;
+}
+
+.card {
+ width: 200px;
+ border: 1px solid;
+ margin: 10px;
+ padding: 10px;
+ height: 100px;
+ position: relative;
+}
+
+.remove {
+ position: absolute;
+ top: -9px;
+ right: -10px;
+}
\ No newline at end of file
diff --git a/src/app/list/list.component.html b/src/app/list/list.component.html
index e4b0765..f0eb5be 100644
--- a/src/app/list/list.component.html
+++ b/src/app/list/list.component.html
@@ -1,4 +1,40 @@
Providers
+
+
+
+
Provided List
+
+
+
+ {{item.name}}
+
{{item.address}}
+
+
+
+
+ no record
+
+
+
+
+
+
+
Selected Provided List
+
+
+
+ {{item.name}}
+
{{item.address}}
+
+
+
+
+ no record
+
+
+
+
+
diff --git a/src/app/list/list.component.spec.ts b/src/app/list/list.component.spec.ts
index 59bde51..a65e008 100644
--- a/src/app/list/list.component.spec.ts
+++ b/src/app/list/list.component.spec.ts
@@ -38,4 +38,17 @@ describe('ListComponent', () => {
expect(component.selectedProviders.length).toEqual(0);
});
});
+
+ describe('provider selection and deselection', () => {
+ it('should select provider', () => {
+ component.select(component.unselectedProviders[0], 0);
+ expect(component.selectedProviders.length).toEqual(1);
+ });
+
+ it('should deselect provider', () => {
+ component.select(component.unselectedProviders[0], 0);
+ component.deselect(component.selectedProviders[0], 0);
+ expect(component.unselectedProviders.length).toEqual(3);
+ });
+ });
});
diff --git a/src/app/list/list.component.ts b/src/app/list/list.component.ts
index 8a50db6..acb760c 100644
--- a/src/app/list/list.component.ts
+++ b/src/app/list/list.component.ts
@@ -31,6 +31,28 @@ export class ListComponent implements OnInit {
constructor() {}
- ngOnInit() {}
+ ngOnInit() {
+ try {
+ let data = sessionStorage.getItem('selectedItems');;
+ data = data ? JSON.parse(data) : [];
+ this.selectedProviders = this.selectedProviders.concat(data);
+ this.unselectedProviders = this.unselectedProviders.filter(item => this.selectedProviders.findIndex(subitem => subitem.id === item.id) === -1);
+ } catch (e) {}
+ }
+
+ select(item, index) {
+ console.log('hi', index)
+ this.unselectedProviders.splice(index, 1);
+ this.selectedProviders.push(item);
+ sessionStorage.setItem('selectedItems', JSON.stringify(this.selectedProviders));
+ }
+
+ deselect(item, index) {
+ console.log('bye', index)
+
+ this.selectedProviders.splice(index, 1);
+ this.unselectedProviders.push(item);
+ sessionStorage.setItem('selectedItems', JSON.stringify(this.selectedProviders));
+ }
}