-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from adiwg/feature-33-record-dashboards
Feature 33 record dashboards
- Loading branch information
Showing
9 changed files
with
270 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.findAll('contact'); | ||
}, | ||
|
||
actions: { | ||
deleteItem: function(item) { | ||
let message = | ||
"Do you really want to delete this contact?\n\n" + | ||
"Be sure this contact is not referenced by a metadata record or dictionary " + | ||
"or it's deletion may cause those records to not validate."; | ||
this._deleteItem(item, message); | ||
}, | ||
|
||
editItem: function(item) { | ||
this.transitionTo('contact.show.edit', item); | ||
} | ||
}, | ||
|
||
// action methods | ||
_deleteItem(item, message) { | ||
if (window.confirm(message)) { | ||
item.destroyRecord().then(function() { | ||
console.log('+-- deleted contact ID:', item.id); | ||
}, function() { | ||
console.log('+-- delete contact failed'); | ||
}); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
<h3>Contacts Dashboard</h3> | ||
<div class="container-fluid"> | ||
<br> | ||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<th></th> | ||
<th>#</th> | ||
<th>Contact ID</th> | ||
<th>Individual Name</th> | ||
<th>Organization Name</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{{#each model key="@index" as |item index|}} | ||
<tr> | ||
<td>{{input type="checkbox" name="isChecked"}}</td> | ||
<td>{{index}}</td> | ||
<td>{{item.json.contactId}}</td> | ||
<td>{{item.json.individualName}}</td> | ||
<td>{{item.json.organizationName}}</td> | ||
<td> | ||
<button class="btn btn-xs btn-danger pull-right" {{action "deleteItem" item}}> | ||
<span class="fa fa-times"></span> Delete | ||
</button> | ||
<span class="pull-right"> </span> | ||
<button class="btn btn-xs btn-warning pull-right" {{action "editItem" item}}> | ||
<span class="fa fa-pencil"></span> Edit | ||
</button> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,33 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
model() { | ||
return this.store.findAll('dictionary'); | ||
}, | ||
|
||
actions: { | ||
deleteItem: function(item) { | ||
let message = | ||
"Do you really want to delete this dictionary?\n\n" + | ||
"Be sure this dictionary is not referenced by an metadata records " + | ||
"or it's deletion may cause those records to not validate."; | ||
this._deleteItem(item, message); | ||
}, | ||
|
||
editItem: function(item) { | ||
this.transitionTo('dictionary.show.edit', item); | ||
} | ||
}, | ||
|
||
// action methods | ||
_deleteItem(item, message) { | ||
if (window.confirm(message)) { | ||
item.destroyRecord().then(function() { | ||
console.log('+-- deleted dictionary ID:', item.id); | ||
}, function() { | ||
console.log('+-- delete dictionary failed'); | ||
}); | ||
} | ||
} | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
List Dictionaries | ||
<h3>Dictionary Dashboard</h3> | ||
<div class="container-fluid"> | ||
<br> | ||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<th></th> | ||
<th>#</th> | ||
<th>Dictionary Name</th> | ||
<th>Data Resource Type</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{{#each model key="@index" as |item index|}} | ||
<tr> | ||
<td>{{input type="checkbox" name="isChecked"}}</td> | ||
<td>{{index}}</td> | ||
<td>{{item.json.dictionaryInfo.citation.title}}</td> | ||
<td>{{item.json.dictionaryInfo.resourceType}}</td> | ||
<td> | ||
<button class="btn btn-xs btn-danger pull-right" {{action "deleteItem" item}}> | ||
<span class="fa fa-times"></span> Delete | ||
</button> | ||
<span class="pull-right"> </span> | ||
<button class="btn btn-xs btn-warning pull-right" {{action "editItem" item}}> | ||
<span class="fa fa-pencil"></span> Edit | ||
</button> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,33 @@ | ||
<h3>List of records.</h3> | ||
|
||
<div class="bs-example" data-example-id="contextual-table"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<h3>Metadata Record Dashboard</h3> | ||
<div class="container-fluid"> | ||
<br> | ||
<table class="table table-striped table-hover"> | ||
<thead> | ||
<th></th> | ||
<th>#</th> | ||
<th>Column heading</th> | ||
<th>Column heading</th> | ||
<th>Column heading</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr class="active"> | ||
<th scope="row">1</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">2</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr class="success"> | ||
<th scope="row">3</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">4</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr class="info"> | ||
<th scope="row">5</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">6</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr class="warning"> | ||
<th scope="row">7</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">8</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
<tr class="danger"> | ||
<th scope="row">9</th> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
<td>Column content</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<th>Record Name</th> | ||
<th>Resource Type</th> | ||
<th></th> | ||
</thead> | ||
<tbody> | ||
{{#each model key="@index" as |item index|}} | ||
<tr> | ||
<td>{{input type="checkbox" name="isChecked"}}</td> | ||
<td>{{index}}</td> | ||
<td>{{item.json.metadata.resourceInfo.citation.title}}</td> | ||
<td>{{item.json.metadata.resourceInfo.resourceType}}</td> | ||
<td> | ||
<button class="btn btn-xs btn-danger pull-right" {{action "deleteItem" item}}> | ||
<span class="fa fa-times"></span> Delete | ||
</button> | ||
<span class="pull-right"> </span> | ||
<button class="btn btn-xs btn-warning pull-right" {{action "editItem" item}}> | ||
<span class="fa fa-pencil"></span> Edit | ||
</button> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,38 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
let originalConfirm; | ||
|
||
moduleFor('route:contacts', 'Unit | Route | contacts', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
beforeEach() { | ||
originalConfirm = window.confirm; | ||
}, | ||
|
||
afterEach() { | ||
window.confirm = originalConfirm; | ||
} | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
var route = this.subject(); | ||
assert.ok(route); | ||
}); | ||
|
||
test('should display a confirm', function(assert) { | ||
assert.expect(2); | ||
|
||
let route = this.subject(); | ||
|
||
// test _deleteItem to displays the expected window.confirm message | ||
const expectedTextFoo = 'foo'; | ||
window.confirm = (message) => { | ||
assert.equal(message, expectedTextFoo, 'expect confirm to display ${expectedTextFoo}'); | ||
}; | ||
route._deleteItem(0, expectedTextFoo); | ||
|
||
// test action deleteItem calls _deleteItem and displays a window.confirm | ||
window.confirm = (message) => { | ||
assert.ok(message, 'expect confirm to display a message'); | ||
}; | ||
route.send('deleteItem', 0); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
let originalConfirm; | ||
|
||
moduleFor('route:dictionaries', 'Unit | Route | dictionaries', { | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
beforeEach() { | ||
originalConfirm = window.confirm; | ||
}, | ||
|
||
afterEach() { | ||
window.confirm = originalConfirm; | ||
} | ||
}); | ||
|
||
test('it exists', function(assert) { | ||
var route = this.subject(); | ||
assert.ok(route); | ||
}); | ||
|
||
test('should display a confirm', function(assert) { | ||
assert.expect(2); | ||
|
||
let route = this.subject(); | ||
|
||
// test _deleteItem to displays the expected window.confirm message | ||
const expectedTextFoo = 'foo'; | ||
window.confirm = (message) => { | ||
assert.equal(message, expectedTextFoo, 'expect confirm to display ${expectedTextFoo}'); | ||
}; | ||
route._deleteItem(0, expectedTextFoo); | ||
|
||
// test action deleteItem calls _deleteItem and displays a window.confirm | ||
window.confirm = (message) => { | ||
assert.ok(message, 'expect confirm to display a message'); | ||
}; | ||
route.send('deleteItem', 0); | ||
|
||
}); | ||
|
Oops, something went wrong.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to fix before merging:
console.log
<br>
tags for layout, use CSS if needed<span class="pull-right"> </span>
for layout, use CSS if neededkey=@index
is unnecessary, see here and heref8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can easily adjust this with CSS. For example:
I'm not sure what the dashboard is going to look like in the end, so I wouldn't worry about it too much right now.
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the link above, the key defaults to
@guid
or@item
. See also here. It's just redundant unless you want to use something other than the defaults.f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WE shouldn't have console.logs in the production app (or dev branch). We really should employ a universal messaging framework, some thing like this: http://simonwade.me/assets/ember-demos/#/ember-notify
f8f4a92
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.