Added tag relationship management to frontend

This commit is contained in:
Marcin Kurczewski 2014-10-15 20:07:45 +02:00
parent 5815f156a8
commit a8cb78382c
4 changed files with 38 additions and 5 deletions

4
TODO
View file

@ -29,10 +29,6 @@ everything related to tags:
- category (from config.ini) - category (from config.ini)
- description - description
- relations - relations
- handle tag relations editing in frontend
- privileges
- template
- ajax
- handle relations in autocomplete - handle relations in autocomplete
refactors: refactors:

View file

@ -20,6 +20,13 @@
#tag-view form { #tag-view form {
text-align: left; text-align: left;
max-width: 20em; max-width: 30em;
margin: 0 auto; margin: 0 auto;
} }
#tag-view p {
margin: 0 0 0.5em 0;
line-height: normal;
}
#tag-view small {
font-size: 12px;
}

View file

@ -28,6 +28,8 @@ App.Presenters.TagPresenter = function(
topNavigationPresenter.changeTitle('Tags'); topNavigationPresenter.changeTitle('Tags');
privileges.canChangeName = auth.hasPrivilege(auth.privileges.changeTagName); privileges.canChangeName = auth.hasPrivilege(auth.privileges.changeTagName);
privileges.canChangeImplications = auth.hasPrivilege(auth.privileges.changeTagImplications);
privileges.canChangeSuggestions = auth.hasPrivilege(auth.privileges.changeTagSuggestions);
privileges.canBan = auth.hasPrivilege(auth.privileges.banTags); privileges.canBan = auth.hasPrivilege(auth.privileges.banTags);
promise.wait( promise.wait(
@ -86,6 +88,14 @@ App.Presenters.TagPresenter = function(
formData.banned = $form.find('[name=ban]').is(':checked') ? 1 : 0; formData.banned = $form.find('[name=ban]').is(':checked') ? 1 : 0;
} }
if (privileges.canChangeImplications) {
formData.implications = $form.find('[name=implications]').val();
}
if (privileges.canChangeSuggestions) {
formData.suggestions = $form.find('[name=suggestions]').val();
}
promise.wait(api.put('/tags/' + tag.name, formData)) promise.wait(api.put('/tags/' + tag.name, formData))
.then(function(response) { .then(function(response) {
tag = response.json; tag = response.json;

View file

@ -26,6 +26,26 @@
</div> </div>
<% } %> <% } %>
<% if (privileges.canChangeImplications) { %>
<div class="form-row">
<label class="form-label" for="tag-implications">Implications:</label>
<div class="form-input">
<input maxlength="200" type="text" name="implications" id="tag-implications" placeholder="tag1, tag2&hellip;" value="<%= _.pluck(tag.implications, 'name').join(' ') %>"/>
<p><small>Added automatically when tagging with <strong><%= tagName %></strong>.</small></p>
</div>
</div>
<% } %>
<% if (privileges.canChangeSuggestions) { %>
<div class="form-row">
<label class="form-label" for="tag-suggestions">Suggestions:</label>
<div class="form-input">
<input maxlength="200" type="text" name="suggestions" id="tag-suggestions" placeholder="tag1, tag2&hellip;" value="<%= _.pluck(tag.suggestions, 'name').join(' ') %>"/>
<p><small>Suggested when tagging with <strong><%= tagName %></strong>.</small></p>
</div>
</div>
<% } %>
<div class="form-row"> <div class="form-row">
<label class="form-label"></label> <label class="form-label"></label>
<div class="form-input"> <div class="form-input">