Refactor complete step button

This commit is contained in:
Mojca Lorber 2020-09-15 11:18:15 +02:00
parent eeb8f4a97a
commit fe7d922cc5
4 changed files with 16 additions and 37 deletions

View file

@ -77,21 +77,14 @@
button = step.find("[data-action='complete-step']");
button.attr("data-action", "uncomplete-step");
button.find(".btn").removeClass("btn-toggle").addClass("btn-default");
button.find("button").html('<span class="fas fa-times"></span>&nbsp;' + data.new_title);
if (data.task_ready_to_complete) {
$('#completed-task-modal').modal('show');
complete_my_module_actions();
}
button.html('<span class="fas fa-times"></span>&nbsp;' + data.new_title);
}
else {
step.addClass("not-completed").removeClass("completed");
button = step.find("[data-action='uncomplete-step']");
button.attr("data-action", "complete-step");
button.find(".btn").removeClass("btn-default").addClass("btn-toggle");
button.find("button").html('<span class="fas fa-check"></span>&nbsp;' + data.new_title);
button.html('<span class="fas fa-check"></span>&nbsp;' + data.new_title);
}
},
error: function(response) {

View file

@ -166,10 +166,6 @@
display: flex;
flex-wrap: wrap;
max-width: 100%;
.complete-step-btn {
width: 100%;
}
}
}

View file

@ -58,14 +58,6 @@
}
}
.complete-step-btn {
display: inline-block;
&.disabled {
pointer-events: none;
}
}
.step-heading {
align-items: center;
border: 0;

View file

@ -28,23 +28,21 @@
</div>
<div class="panel-options pull-right">
<% if step.completed? %>
<div data-action="uncomplete-step"
class="complete-step-btn <%= 'disabled' unless can_complete_or_checkbox_step?(@protocol) && !(preview) %>"
data-link-url="<%= toggle_step_state_step_path(step)%>">
<button class="btn btn-secondary btn-block <%= 'disabled' unless can_complete_or_checkbox_step?(@protocol) && !(preview) %>">
<span class="fas fa-times"></span>
<%= t("protocols.steps.options.uncomplete_title") %>
</button>
</div>
<button data-action="uncomplete-step"
data-link-url="<%= toggle_step_state_step_path(step)%>"
class="btn btn-secondary"
<%= 'disabled' if !can_complete_or_checkbox_step?(@protocol) || preview %>>
<span class="fas fa-times"></span>
<%= t("protocols.steps.options.uncomplete_title") %>
</button>
<% else %>
<div data-action="complete-step"
class="complete-step-btn <%= 'disabled' unless can_complete_or_checkbox_step?(@protocol) && !(preview) %>"
data-link-url="<%= toggle_step_state_step_path(step)%>">
<button class="btn btn-secondary btn-block <%= 'disabled' unless can_complete_or_checkbox_step?(@protocol) && !(preview) %>">
<span class="fas fa-check"></span>
<%= t("protocols.steps.options.complete_title") %>
</button>
</div>
<button data-action="complete-step"
data-link-url="<%= toggle_step_state_step_path(step)%>"
class="btn btn-secondary"
<%= 'disabled' if !can_complete_or_checkbox_step?(@protocol) || preview %>>
<span class="fas fa-check"></span>
<%= t("protocols.steps.options.complete_title") %>
</button>
<% end %>
<% if (can_manage_protocol_in_module?(@protocol) ||