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
CollectionView page #468
CollectionView page #468
Conversation
@MonkeyDo What do you think of thiss? I've created only |
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.
Great job reusing the existing entity tables, that's 100% the way to go.
And now that you're adding checkboxes, it will allow us in the future to add batch actions easily !
.then((res) => { | ||
window.location.href = `/collection/${this.props.collection.id}`; | ||
}, (error) => { | ||
this.setState({error: 'Internal Error'}); |
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.
Same as in the other PR, it would be great if this was a more user-friendly error message
<Alert bsStyle="danger">{this.state.error}</Alert> : null; | ||
const EntityTable = getEntityTable(this.props.collection.entityType); | ||
const propsForTable = { | ||
[this.entityKey]: this.props.entities, |
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.
That's a smart way to solve the issue of each entity table requiring a specific named key. Nice!
<h1><strong>{this.props.collection.name}</strong></h1> | ||
<h4>{this.props.collection.description}</h4> |
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 you can get the formatting closer to the existing entity pages, and also use a big entity icon. (I was originally thinking the icon of the entity type)
<hr/> | ||
{ | ||
this.props.isOwner ? | ||
<ButtonGroup className="pull-right margin-bottom-1"> |
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 wonder if it would make more sense to show these buttons below the entity table, along with the batch remove button.
If that doesn't work out well, I'd suggest having the buttons left aligned rather than right-aligned
className="pull-left margin-top-1" | ||
onClick={this.handleRemoveEntities} | ||
> | ||
<FontAwesomeIcon icon="times"/> |
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.
<FontAwesomeIcon icon="times"/> | |
<FontAwesomeIcon icon="times-circle"/> |
I think here the times-circle icon will be ideal
src/server/routes/collection.js
Outdated
const {orm} = req.app.locals; | ||
const relations = getEntityRelations(collection.entityType); | ||
|
||
const entitiesPromise = collection.items.map(item => orm.func.entity.getEntity(orm, collection.entityType, item.bbid, relations)); |
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.
In the future we might want to think about optimizing this to fetch all the entities in a single batch, but that's for another day.
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'll add this to that doc
src/server/routes/collection.js
Outdated
@@ -80,9 +140,23 @@ router.get('/:collectionId/edit', auth.isAuthenticated, auth.isCollectionOwner, | |||
|
|||
router.post('/:collectionId/edit/handler', auth.isAuthenticatedForHandler, auth.isCollectionOwner, collectionCreateOrEditHandler); | |||
|
|||
router.get('/:collectionId', (req, res) => { | |||
router.post('/:collectionId/remove', auth.isAuthenticated, auth.isCollectionOwnerOrCollaborator, async (req, res) => { | |||
const {bbids} = req.body; |
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 probably want to send a detailed error if there are no bbids (missing in body or empty array)
src/server/routes/collection.js
Outdated
const promiseArray = bbids.map((bbid) => | ||
new UserCollectionItem() | ||
.where('bbid', bbid) | ||
.where('collection_id', collection.id) | ||
.destroy() | ||
); | ||
await Promise.all(promiseArray); |
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 wonder if you could do this in one batch instead of multiple calls?
Perhaps using Bookshelf's collections ?
089c4dd
to
b55c56d
Compare
@MonkeyDo Have a look at this. Also should there be an identifier in Publisher, Work, Author Table? if yes then which? |
ISBNs for Editions is a distinguishing feature, I don't think we want to show any particular identifier for the other entities. We'll also want pagination for the collection items, looking at reosarevok's collection of 7189 artists… |
Also I think disabling the "Remove selected work" button rather than hiding it would be better, I find changes in layout are not appreciated by users if they can be avoided. Apart from that it's looking good! It feels like a full workflow for the first time, it's really nice to see it all come together :) |
@MonkeyDo Have a look at this |
I also noticed couple of bugs. One in |
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.
Pagination works great, instant improvement !
Placement of the collection edit buttons looks good to me.
With that in place, do you think we want to display the total number of items somewhere in the collection attributes, or do we rely only on the pagination count? I suppose the same column in the collections page would make sense. I'll add that to the google doc.
Also how do you feel about a "clear selection" button?
A line I couldn't comment on directly but that you can change in this PR is line 273 of src/server/routes/collection.js:
res.status(500).send();
-> next(err);
// get next enabled for pagination | ||
const {newResultsArray, nextEnabled} = utils.getNextEnabledAndResultsArray(bbids, size); | ||
// load entities from bbids | ||
const entitiesPromise = newResultsArray.map(bbid => orm.func.entity.getEntity(orm, collection.entityType, bbid, relations)); |
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 need to optimize this at some point to fetch all the entities in one go.
Thinking a bout it again, perhaps there should be a |
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.
OK, this is in a good state now, looking nice !
I've got one final item I just noticed. Apart from that I think it's ready to merge !
is this alright? or should this be done in css class in |
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.
Awesome, good to go !
Problem
CollectionView Page