-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow users to create deliveries #21
Changes from 15 commits
7cef82e
d52c6c5
708831c
695fa85
466b672
cb44c00
44781cd
50ca344
d5f092f
dbbe482
d543d4e
6d77719
15da3a8
2871f01
068ddab
3bf70ad
2b9d464
fecb96f
377c191
193f960
e6ee8e2
b493477
ecb4cc2
4b821bb
ff92e30
780c7b9
91c45b5
2ddd7d6
1168694
ff42d3a
cba5f81
189d961
6f229f9
2b4f7af
310d18d
34b2205
cb9141d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ApplicationAdapter from './application'; | ||
|
||
export default ApplicationAdapter.extend({ | ||
urlForQuery(query) { | ||
const projectId = query.project; | ||
delete query.project; // remove project from query so it will not be appended to the url | ||
return this.buildURL('duke-ds-project') + projectId + '/permissions/'; | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import Ember from 'ember'; | ||
|
||
const PROJECT_ADMIN_AUTH_ROLE = 'project_admin'; | ||
|
||
export default Ember.Controller.extend({ | ||
project: null, | ||
application: Ember.inject.controller(), | ||
|
@@ -24,7 +26,7 @@ export default Ember.Controller.extend({ | |
} | ||
}), | ||
currentUserCanDeliver: Ember.computed('currentUserProjectAuthRole', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this be |
||
return this.get('currentUserProjectAuthRole') == 'project_admin'; | ||
return this.get('currentUserProjectAuthRole') == PROJECT_ADMIN_AUTH_ROLE; | ||
}), | ||
disableNext: Ember.computed.not('currentUserCanDeliver'), | ||
showUserMissingPrivilegesError: Ember.computed('project.id', 'currentUserProjectAuthRole', function () { | ||
|
@@ -35,7 +37,7 @@ export default Ember.Controller.extend({ | |
if (!authRole) { | ||
return false; //do not show error while we are fetching users auth role for this project | ||
} | ||
return authRole != 'project_admin'; | ||
return authRole != PROJECT_ADMIN_AUTH_ROLE; | ||
}), | ||
actions: { | ||
projectSelectionChanged(actionData) { | ||
|
@@ -44,7 +46,6 @@ export default Ember.Controller.extend({ | |
selectedItem = actionData.selectedItems[0]; | ||
} | ||
this.set('project', selectedItem); | ||
this.set('showMissingPrivilegesError', false); | ||
}, | ||
back() { | ||
this.transitionToRoute('deliveries'); | ||
|
@@ -54,8 +55,6 @@ export default Ember.Controller.extend({ | |
if (projectId) { | ||
if (this.get('currentUserCanDeliver')) { | ||
this.transitionToRoute('deliveries.new.select-recipient', { queryParams: { projectId: projectId }}) | ||
} else { | ||
this.set('showMissingPrivilegesError', true); | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,21 @@ export default Ember.Controller.extend({ | |
}), | ||
application: Ember.inject.controller(), | ||
currentDukeDsUser: Ember.computed.alias('application.currentDukeDsUser'), | ||
otherUsersList: Ember.computed('model.[]', 'currentDukeDsUser', function () { | ||
validUsersList: Ember.computed('model.[]', function () { | ||
// remove users with invalid fullName values | ||
return this.get('model') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see users in my listing with empty email addresses too. Won't this be problematic too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added code to filter out users without emails. |
||
.rejectBy('fullName', null) | ||
.rejectBy('fullName', '(null)'); | ||
}), | ||
otherUsersList: Ember.computed('validUsersList.[]', 'currentDukeDsUser', function () { | ||
const currentDukeDSUser = this.get('currentDukeDsUser'); | ||
if (currentDukeDSUser) { | ||
return this.get('model').rejectBy('id', currentDukeDSUser.get('id')); | ||
return this.get('validUsersList').rejectBy('id', currentDukeDSUser.get('id')); | ||
} else { | ||
return this.get('model'); | ||
return this.get('validUsersList'); | ||
} | ||
}), | ||
toUser: null, | ||
shareUsers: null, | ||
disableNext: Ember.computed.not('toUser'), | ||
actions: { | ||
toUserSelectionChanged(actionData) { | ||
|
@@ -27,25 +32,16 @@ export default Ember.Controller.extend({ | |
} | ||
this.set('toUser', selectedItem); | ||
}, | ||
shareUsersSelectionChanged(actionData) { | ||
this.set('shareUsers', actionData.selectedItems); | ||
}, | ||
back() { | ||
this.transitionToRoute('deliveries.new.select-project'); | ||
}, | ||
next() { | ||
const projectId = this.get('projectId'); | ||
const toUserId = this.get('toUser.id'); | ||
const shareUsers = this.get('shareUsers'); | ||
var shareUserIds = null; | ||
if (shareUsers) { | ||
shareUserIds = shareUsers.mapBy('id').join(','); | ||
} | ||
this.transitionToRoute('deliveries.new.enter-user-message', { | ||
queryParams: { | ||
projectId: projectId, | ||
toUserId: toUserId, | ||
shareUserIds: shareUserIds | ||
} | ||
}); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
resetController(controller, isExiting) { | ||
if (isExiting) { | ||
controller.set('errors', null); | ||
} | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,5 @@ | |
showColumnsDropdown=false | ||
showGlobalFilter=false | ||
showPageSize=false | ||
pageSize=12 | ||
pageSize=20 | ||
}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
showGlobalFilter=false | ||
showPageSize=false | ||
pageSize=12 | ||
filteringIgnoreCase=true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wish I had known about this before! |
||
displayDataChangedAction=(action "displayDataChanged") | ||
}} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<span class="{{if isSelected themeInstance.select-row themeInstance.deselect-row}}" onclick={{action "clickOnRow" index record}}></span> | ||
<span class="{{if isSelected themeInstance.select-row themeInstance.deselect-row}}" onclick={{action "clickOnRow" index record}}></span> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{{delivery-breadcrumbs selectedRouteName="deliveries.index"}} | ||
<h2>All Deliveries</h2> | ||
|
||
{{delivery-table model currentDukeDsUser}} | ||
{{delivery-table model currentDukeDsUser}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { moduleFor, test } from 'ember-qunit'; | ||
|
||
moduleFor('adapter:duke-ds-project-permission', 'Unit | Adapter | duke ds project permission', { | ||
// Specify the other units that are required for this test. | ||
needs: ['service:session'] | ||
}); | ||
|
||
test('it returns duke-ds-project permisions sub route for urlForQuery', function(assert) { | ||
let adapter = this.subject(); | ||
let url = adapter.urlForQuery({project: 'project1'}, 'duke-ds-project-permission'); | ||
assert.equal(url, 'http://testhost/duke-ds-projects/project1/permissions/') | ||
}); |
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.
I think I follow this, but I wanted to clarify.
In the discussion of Duke-GCB/D4S2#170, I argued that it didn't make sense for the API to have a required query parameter to fetch project permissions. I recognize that, without a proper
hasMany
relationship to get the related records, Ember Data offersstore.query()
to do fetch a filtered list for a resource, and this code overrides the default query implementation to work with the project detail route in Duke-GCB/D4S2#170. I think it's probably worth a comment about why this is here.I'll follow up with an issue, but I wanted to have a discussion on whether or not it makes sense to just make ajax calls for the project permissions instead of shoehorning them into ember data models.
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.
My understanding is the
hasMany
relationship requires a top level endpoint to get the related keys (ie./duke-ds-project-permission/<id>
). I'm all for just making an ajax call, but not sure how easy it would be to re-use the emberjs auth.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.
Yeah I think we're on the same page - I was mostly trying to think out loud as to why this is done this way. Through the course of that I think I came to the conclusion that this doesn't fit 100% in a vanilla Ember Data store, but there are ways to make an authenticated AJAX call here and customize how the response is handled. We do it in bespin-ui.
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.
See #22
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.
I added a comment to the adapter.