Skip to content
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

Merged
merged 23 commits into from Jul 8, 2020
Merged

Conversation

prabalsingh24
Copy link
Contributor

Problem

CollectionView Page

@prabalsingh24
Copy link
Contributor Author

prabalsingh24 commented Jun 29, 2020

@MonkeyDo What do you think of thiss? I've created only EditionCollection page right now. If you think this is alright, I will create other EntityTables similar to this as well

Screenshot_2020-06-29 BookBrainz – The Open Book Database(2)

@coveralls
Copy link

coveralls commented Jun 29, 2020

Coverage Status

Coverage decreased (-0.8%) to 58.182% when pulling 62e9f7c on prabalsingh24:CollectionPage into 63e6a53 on bookbrainz:UserCollection.

@prabalsingh24
Copy link
Contributor Author

I made collectionView page for Work also. Reused the existing Work-Table

Screenshot_2020-06-29 BookBrainz – The Open Book Database(3)

Copy link
Contributor

@MonkeyDo MonkeyDo left a 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'});
Copy link
Contributor

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,
Copy link
Contributor

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!

Comment on lines 107 to 108
<h1><strong>{this.props.collection.name}</strong></h1>
<h4>{this.props.collection.description}</h4>
Copy link
Contributor

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">
Copy link
Contributor

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"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<FontAwesomeIcon icon="times"/>
<FontAwesomeIcon icon="times-circle"/>

I think here the times-circle icon will be ideal

src/client/stylesheets/style.less Outdated Show resolved Hide resolved
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));
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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;
Copy link
Contributor

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)

Comment on lines 148 to 166
const promiseArray = bbids.map((bbid) =>
new UserCollectionItem()
.where('bbid', bbid)
.where('collection_id', collection.id)
.destroy()
);
await Promise.all(promiseArray);
Copy link
Contributor

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 ?

src/server/routes/collection.js Outdated Show resolved Hide resolved
@prabalsingh24
Copy link
Contributor Author

prabalsingh24 commented Jul 3, 2020

@MonkeyDo Have a look at this. Also should there be an identifier in Publisher, Work, Author Table? if yes then which?
There is ISBN identifier row in EditionTable..

@MonkeyDo
Copy link
Contributor

MonkeyDo commented Jul 3, 2020

Also should there be an identifier in Publisher, Work, Author Table? if yes then which?
There is ISBN identifier row in EditionTable..

ISBNs for Editions is a distinguishing feature, I don't think we want to show any particular identifier for the other entities.
However, for Publishers, let's show Date Founded and Date Disolved
Not much more to show for Edition Groups.
For Authors we can also show additional info like date and place of birth, date and place of death (empty if ended=false).

We'll also want pagination for the collection items, looking at reosarevok's collection of 7189 artists…
If you want that can be done in a separate PR, in case it requires to refactor a bunch of other components, to limit the scope.

@MonkeyDo
Copy link
Contributor

MonkeyDo commented Jul 3, 2020

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 :)

@prabalsingh24
Copy link
Contributor Author

Screenshot_2020-07-04 BookBrainz – The Open Book Database(1)

@prabalsingh24
Copy link
Contributor Author

@MonkeyDo Have a look at this

@prabalsingh24
Copy link
Contributor Author

I also noticed couple of bugs. One in UserCollectionForm and other in Editor Collection Page. I will solve them in different PR.

Copy link
Contributor

@MonkeyDo MonkeyDo left a 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);

src/client/components/pages/entities/editionGroup-table.js Outdated Show resolved Hide resolved
src/client/components/pages/entities/editionGroup-table.js Outdated Show resolved Hide resolved
// 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));
Copy link
Contributor

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.

src/server/routes/collection.js Outdated Show resolved Hide resolved
src/server/routes/collection.js Outdated Show resolved Hide resolved
src/server/routes/collection.js Outdated Show resolved Hide resolved
src/server/routes/collection.js Outdated Show resolved Hide resolved
@MonkeyDo
Copy link
Contributor

MonkeyDo commented Jul 6, 2020

Thinking a bout it again, perhaps there should be a count or entitiesCount method on the ORM model to count the UserCollectionItems?
https://bookshelfjs.org/api.html#Model-instance-count

Copy link
Contributor

@MonkeyDo MonkeyDo left a 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 !

src/client/components/pages/entities/publisher-table.js Outdated Show resolved Hide resolved
@prabalsingh24
Copy link
Contributor Author

is this alright? or should this be done in css class in style.less ?

Copy link
Contributor

@MonkeyDo MonkeyDo left a 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 !

@MonkeyDo MonkeyDo merged commit 06ece0c into metabrainz:UserCollection Jul 8, 2020
@prabalsingh24 prabalsingh24 deleted the CollectionPage branch July 11, 2020 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants