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

[RFR] View title: Use template #152

Merged
merged 7 commits into from
Dec 1, 2014
Merged

[RFR] View title: Use template #152

merged 7 commits into from
Dec 1, 2014

Conversation

fzaninotto
Copy link
Member

This PR deeply changes the way view titles are handled. Functions are not accepted anymore by View.title() - only strings. But, and "that is a big but", the string is interpreted as a template, and has access to the raw entry. That allows to customize the view title as follows:

post.editionView().title('Edit post "{{ entry.values.title }}"');

image

In addition, the default view titles are now better. For instance, for an Entity('posts'):

I had to add inflection to handle singularization/pluralization. It's a good library, and I believe we will use it on other places (first, to remove default field label camel case).

I also chose to remove Entity.addMappedField(), and to add all non-mapped properties of the rawEntry from the response to the Entry by default. This removes a big WTF effect I had when trying to customize the deletionView title, and has no side effects.

Lastly, to allow the view title to support both a template and a default template, I updated the Compile directive to make it transclusive. This was a prerequisite for #118, so it goes in the right direction.

Closes #141.

@@ -1,16 +1,18 @@
/*global define*/

var inflection;
Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't find another way to make the inflection object available to the ngInflection filters. I'm not satisfied with it, there must be a better solution. Ping @manuquentin.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can maybe use the requirejs shim.exports to specify the global variable name. You should also mark inflection as a dependency of ngInflection in the requireJS configuration

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried ; it doesn't work. Besides, the inflection lib seems to support RequireJS, so I don't understand.

manuquentin added a commit that referenced this pull request Dec 1, 2014
@manuquentin manuquentin merged commit 15775f5 into master Dec 1, 2014
@manuquentin manuquentin deleted the view_title_template branch December 1, 2014 10:50
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.

Allow to override deletion message
2 participants