Skip to content

New feature: set a note as favorite (star/unstar)#248

Merged
Henni merged 7 commits into
owncloud:masterfrom
korelstar:favorite-feature
Oct 21, 2016
Merged

New feature: set a note as favorite (star/unstar)#248
Henni merged 7 commits into
owncloud:masterfrom
korelstar:favorite-feature

Conversation

@korelstar

@korelstar korelstar commented Oct 16, 2016

Copy link
Copy Markdown
Contributor

This pull request brings a star/unstar-feature for notes as known already from other owncloud apps: you can click on a gray star to mark a note as your favorite, then the note is shown on the top of the list and a yellow star appears, so you can easily find your most important notes.

In the technical backend, it uses the existing system to star files, i.e. a special tag for the file. The frontend provides respective new actions.

closes #202

(Open) tasks

  • provide setting/unsetting notes as favorite (star/unstar)
  • extend API for 3rd-party apps

@mention-bot

Copy link
Copy Markdown

@korelstar, thanks for your PR! By analyzing the history of the files in this pull request, we identified @BernhardPosselt, @Henni and @jancborchardt to be potential reviewers.

@korelstar

korelstar commented Oct 16, 2016

Copy link
Copy Markdown
Contributor Author

For the Notes API, there are multiple approaches for providing this feature to 3rd-party apps, e.g.:

  1. Introduce a new optional field favorite for creating/updating nodes, beside the existing content. Since modified should not be changed by starring a note, content have to be made optional. Then, modified could be updated if and only if a content is given, otherwise only favorite will be updated.
  2. Introduce a new route for meta-data of a note. In the future, this could also include categories or tags. Here, it is clear, that modified will not be updated.

What do you think?

@Henni Henni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I haven't tested it yet and haven't seen the owncloud tags API in practice, but here is a pure code review for now.

Comment thread css/notes.css
#app-navigation .active > .utils .icon-star {
display: inline-block;
opacity: .3;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please merge this rule with the previous rule:

#app-navigation .active > .utils .icon-delete,
#app-navigation .active > .utils .icon-star {
...
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread css/notes.css
#app-navigation .utils .icon-starred {
display: inline-block;
opacity: 1 !important;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It should be possible to remove the !important if the rule is set to:

#app-navigation .active > .utils .icon-starred {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's not possible here, because the starred icon should be shown for not-active notes, too.

Comment thread js/app/services/notesmodel.js Outdated
}
}
}
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where does this , come from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

copy&paste, sorry. It's removed now.

Henni
Henni previously approved these changes Oct 16, 2016
@Henni Henni dismissed their stale review October 16, 2016 19:20

Looks good so far. Needs to be re-reviewed when finished

@Henni Henni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Except for this one issue: Awesome PR!

Comment thread db/note.php Outdated
* @return static
*/
public static function fromFile(File $file){
public static function fromFile(File $file, array $tags=[]){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If there are no favorites, the array annotation results in an Internal Server Error.

image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

BTW: This is also why travis fails.

@korelstar

Copy link
Copy Markdown
Contributor Author

Another thing: The automated tests failed for my pull request, because \OC::$server->getTagManager()->load('files') returns null. However, as far as I know, this is the correct official approach to get an instance of OCP\ITags (which is also used in owncloud/core: e.g., Application, Helper, TagServiceTest) and it works on my installation.

Therefore, I believe that the test environment is not sufficient. However, I have no idea how to change it, so that the tests will be successful. Can anyone help please?

@jancborchardt

Copy link
Copy Markdown
Contributor

Really awesome work @korelstar! :) Great that it directly hooks in with Files, it’s just perfect.

Comment thread db/note.php
* @return static
*/
public static function fromFile(File $file, array $tags=[]){
public static function fromFile(File $file, $tags=[]){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

as soon as travis is happy with this change, I'll merge it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for you feedback. As far as I can see, this was not sufficient. See my above comment: #248 (comment)

@Henni

Henni commented Oct 19, 2016

Copy link
Copy Markdown
Contributor

@korelstar I haven't figured out why travis fails. Maybe you can figure it out:

Call to a member function getTagsForObjects() on a non-object in [...]/apps/notes/service/notesservice.php on line 54

https://travis-ci.org/owncloud/notes/jobs/169027138

@Henni

Henni commented Oct 19, 2016

Copy link
Copy Markdown
Contributor

$tagger might be null if no user is logged in.

@korelstar

Copy link
Copy Markdown
Contributor Author

Which wording should be used? I've chosen favorite, because this term is used by the existing tagging system. However, star/unstar is more neutral and leaves space for other interpretations (e.g, important, to be done, interesting), so I like that wording, too. I think, I prefer this one.

What do you think? I will adjust my changes accordingly.

@jancborchardt @Henni

@Henni

Henni commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

@korelstar I'm happy with both. @jancborchardt what do you prefer?

@Henni

Henni commented Oct 20, 2016

Copy link
Copy Markdown
Contributor

Two things that should be done:

  • Inject TagManager instead of using \OC::$server->getTagManager() (notes uses automatic dependency assembly)
  • Extend tests (requires dependency injection)

I'm also willing to do this. But then I would merge this PR first and fix these two points in a separate PR. (Working on two different repos is painful)

@jancborchardt

Copy link
Copy Markdown
Contributor

Let's go with »Favorite« for now since it's symmetric to how we use it elsewhere. :)

@korelstar

korelstar commented Oct 21, 2016

Copy link
Copy Markdown
Contributor Author

@Henni
That would be nice, if you could do the two tasks.
A few minutes ago, I've added the possibility to set favorites through the API (I used variant 1 of my post above: #248 (comment)). Hence, I'm ready for merge, now!

@Henni

Henni commented Oct 21, 2016

Copy link
Copy Markdown
Contributor

Travis finally has run through.
So 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Star/Unstar

4 participants