mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-27 11:16:10 +01:00
add ui for changing state of context to closed. This fixes #645
This commit is contained in:
parent
acab98d4c7
commit
4df340bd7b
12 changed files with 114 additions and 86 deletions
|
|
@ -12,8 +12,11 @@
|
|||
<label for="context_name"><%= t 'contexts.context_name' %></label><br/>
|
||||
<%= text_field('context', 'name', :class => 'context-name', :tabindex => next_tab_index) %><br/>
|
||||
|
||||
<label for="context_hide"><%= t 'contexts.context_hide' %> </label>
|
||||
<%= check_box_tag('context_state[hide]', 1, context.hidden?, {:class => 'context-hide', :tabindex => next_tab_index}) %>
|
||||
<label for="context_hide"><%= t 'contexts.context_state' %> </label><br/>
|
||||
<% ['active', 'hidden', 'closed'].each do | state | %>
|
||||
<%= radio_button(:context, 'state', state, {:tabindex => next_tab_index}) %> <%= state.titlecase %>
|
||||
<% end %>
|
||||
|
||||
<input type="hidden" name="wants_render" value="true" />
|
||||
|
||||
<div class="submit_box">
|
||||
|
|
|
|||
|
|
@ -2,18 +2,14 @@
|
|||
hide_empty_message();
|
||||
TracksPages.hide_errors();
|
||||
TracksPages.set_page_badge(<%= @down_count %>);
|
||||
add_context("<%=@context.hidden? ? 'hidden' : 'active'%>");
|
||||
add_context("<%=@context.state%>");
|
||||
clear_form();
|
||||
<% else -%>
|
||||
TracksPages.show_errors(html_for_error_messages());
|
||||
<% end -%>
|
||||
|
||||
function hide_empty_message() {
|
||||
<% if @context.hidden? -%>
|
||||
$('div#hidden-contexts-empty-nd').hide();
|
||||
<% else -%>
|
||||
$('div#active-contexts-empty-nd').hide();
|
||||
<% end -%>
|
||||
$('div#<%=@context.state%>-contexts-empty-nd').hide();
|
||||
}
|
||||
|
||||
function add_context(state) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
remove_deleted_context();
|
||||
|
||||
ContextListPage.update_all_states_count(<%=@active_contexts_count%>, <%=@hidden_contexts_count%>)
|
||||
ContextListPage.show_or_hide_all_state_containers(<%= @show_active_contexts %>, <%= @show_hidden_contexts %>);
|
||||
ContextListPage.update_all_states_count(<%=@active_contexts_count%>, <%=@hidden_contexts_count%>, <%=@closed_contexts_count%>)
|
||||
ContextListPage.show_or_hide_all_state_containers(<%= @show_active_contexts %>, <%= @show_hidden_contexts %>, <%= @show_closed_contexts %>);
|
||||
|
||||
TracksPages.set_page_badge(<%=@down_count%>);
|
||||
TracksPages.page_notify('notice', "<%= t('contexts.context_deleted', :name=>@context.name)%>", 5);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<div id="display_box">
|
||||
<%= render :partial => 'context_state_group', :object => @active_contexts, :locals => { :state => 'active', :no_contexts => @no_active_contexts} %>
|
||||
<%= render :partial => 'context_state_group', :object => @hidden_contexts, :locals => { :state => 'hidden', :no_contexts => @no_hidden_contexts} %>
|
||||
<%= render :partial => 'context_state_group', :object => @closed_contexts, :locals => { :state => 'closed', :no_contexts => @no_closed_contexts} %>
|
||||
</div>
|
||||
|
||||
<div id="input_box">
|
||||
|
|
|
|||
|
|
@ -1,42 +1,48 @@
|
|||
<% if @saved -%>
|
||||
<% unless @saved -%>
|
||||
TracksPages.show_edit_errors(html_for_error_messages());
|
||||
|
||||
function html_for_error_messages() {
|
||||
return "<%= escape_javascript(get_list_of_error_messages_for(@context)) %>";
|
||||
}
|
||||
|
||||
<% else -%>
|
||||
TracksPages.page_notify('notice', '<%= t('contexts.save_status_message') %>', 5);
|
||||
|
||||
<% if @state_changed -%>
|
||||
remove_and_re_add_context();
|
||||
update_container_states();
|
||||
<% else -%>
|
||||
replace_context_form_with_updated_context();
|
||||
<% end -%>
|
||||
|
||||
<% else -%>
|
||||
TracksPages.show_edit_errors(html_for_error_messages());
|
||||
<% end -%>
|
||||
function remove_and_re_add_context() {
|
||||
$('#<%=dom_id(@context, 'container')%>').slideUp(500, function() {
|
||||
$('#<%=dom_id(@context, 'container')%>').remove();
|
||||
$('#list-contexts-<%=@new_state%>').append(html_for_context_listing());
|
||||
});
|
||||
}
|
||||
|
||||
function remove_and_re_add_context() {
|
||||
$('#<%=dom_id(@context, 'container')%>').slideUp(500, function() {
|
||||
$('#<%=dom_id(@context, 'container')%>').remove();
|
||||
$('#list-contexts-<%=@new_state%>').append(html_for_context_listing());
|
||||
});
|
||||
}
|
||||
function replace_context_form_with_updated_context() {
|
||||
$('#<%=dom_id(@context, 'container')%>').fadeOut(250, function() {
|
||||
<%
|
||||
# first add the updated context after the old one, then remove old one
|
||||
# using html() does not work, because it will replace the _content_ of
|
||||
# the container instead of the container itself, i.e. you will get
|
||||
# a container within a container which will break drag-and-drop sorting
|
||||
-%>
|
||||
$('#<%=dom_id(@context, 'container')%>').after(html_for_context_listing());
|
||||
$('#<%=dom_id(@context, 'container')%>').remove();
|
||||
$('#<%=dom_id(@context, 'container')%>').fadeIn(500);
|
||||
});
|
||||
}
|
||||
|
||||
function replace_context_form_with_updated_context() {
|
||||
$('#<%=dom_id(@context, 'container')%>').fadeOut(250, function() {
|
||||
<%
|
||||
# first add the updated context after the old one, then remove old one
|
||||
# using html() does not work, because it will replace the _content_ of
|
||||
# the container instead of the container itself, i.e. you will get
|
||||
# a container within a container which will break drag-and-drop sorting
|
||||
-%>
|
||||
$('#<%=dom_id(@context, 'container')%>').after(html_for_context_listing());
|
||||
$('#<%=dom_id(@context, 'container')%>').remove();
|
||||
$('#<%=dom_id(@context, 'container')%>').fadeIn(500);
|
||||
});
|
||||
}
|
||||
function update_container_states() {
|
||||
ContextListPage.update_all_states_count(<%=@active_contexts.count%>, <%=@hidden_contexts.count%>, <%=@closed_contexts.count%>);
|
||||
ContextListPage.show_or_hide_all_state_containers(<%= !@active_contexts.empty? %>, <%= !@hidden_contexts.empty? %>, <%= !@closed_contexts.empty? %>);
|
||||
}
|
||||
|
||||
function html_for_error_messages() {
|
||||
return "<%= escape_javascript(get_list_of_error_messages_for(@context)) %>";
|
||||
}
|
||||
function html_for_context_listing() {
|
||||
return "<%= escape_javascript(render(:partial => 'context_listing', :object => @context))%>";
|
||||
}
|
||||
|
||||
function html_for_context_listing() {
|
||||
return "<%= escape_javascript(render(:partial => 'context_listing', :object => @context))%>";
|
||||
}
|
||||
<% end -%>
|
||||
Loading…
Add table
Add a link
Reference in a new issue