-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5cc0f8c
commit 46bc3ec
Showing
5 changed files
with
104 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,71 @@ | ||
<% | ||
# Define las acciones para el cuestionario | ||
show_action = link_to("Show", questionnaire, data: { turbo_frame: "_top" }, class: "px-3 py-1.5 border border-blue-500 text-blue-500 hover:bg-blue-200 hover:text-blue-700 rounded-md font-medium") | ||
manager_actions = [ | ||
link_to("Edit", edit_questionnaire_path(questionnaire), class: "px-3 py-1.5 border border-blue-500 text-blue-500 hover:bg-blue-200 hover:text-blue-700 rounded-md font-medium"), | ||
button_to("Destroy", questionnaire, method: :delete, data: { turbo_confirm: "Are you sure?" }, class: "px-3 py-1.5 border border-blue-500 text-blue-500 hover:bg-blue-200 hover:text-blue-700 rounded-md font-medium") | ||
link_to("Edit", edit_questionnaire_path(questionnaire), data: { turbo_frame: "_top" }, class: "px-3 py-1.5 border border-blue-500 text-blue-500 hover:bg-blue-200 hover:text-blue-700 rounded-md font-medium", aria: { label: "Edit questionnaire" }), | ||
button_to("Destroy", questionnaire, method: :delete, data: { turbo_confirm: "Are you sure?" }, class: "px-3 py-1.5 border border-red-500 text-red-500 hover:bg-red-200 hover:text-red-700 rounded-md font-medium", aria: { label: "Delete questionnaire" }) | ||
] | ||
|
||
|
||
actions = [] | ||
actions = [ show_action ] unless action_name == "show" | ||
actions.concat(manager_actions) if Current.user.manager? | ||
|
||
# Condicionalmente define las acciones a mostrar | ||
actions = [] | ||
actions = [show_action] unless action_name == "show" | ||
actions.concat(manager_actions) if Current.user.manager? | ||
%> | ||
|
||
<%= render Oodle::CardComponent.new( | ||
title: questionnaire.name, | ||
id: dom_id(questionnaire), | ||
actions: actions | ||
) do%> | ||
|
||
<div id="<%= dom_id questionnaire %>" class="<%= questionnaire.available? ? 'bg-slate-100' : 'bg-slate-400' %> rounded-lg p-12 relative px-8"> | ||
<% if @user_questionnaire.present? %> | ||
<span class="absolute -top-2 -right-2 text-sm text-green-500 rounded-full px-2 py-1 bg-green-100"> | ||
<%= number_to_percentage(@user_questionnaire.progress, precision: 2) %> | ||
</span> | ||
<p class="my-5"> | ||
) do %> | ||
<section id="<%= dom_id(questionnaire) %>" class=" rounded-lg relative px-8 py-6"> | ||
<% if @user_questionnaire.present? %> | ||
<span class="absolute -top-2 -right-2 text-sm text-green-500 rounded-full px-2 py-1 bg-green-100"> | ||
<%= number_to_percentage(@user_questionnaire.progress, precision: 2) %> | ||
</span> | ||
<p class="my-5 flex gap-4"> | ||
<strong class="block font-medium mb-1">Score:</strong> | ||
<%= @user_questionnaire.score.to_f %> | ||
</p> | ||
<% end %> | ||
|
||
<p class="my-5"> | ||
<strong class="block font-medium mb-1">Manager:</strong> | ||
<%= questionnaire.manager_id %> | ||
</p> | ||
<% end %> | ||
|
||
<p class="my-5"> | ||
<strong class="block font-medium mb-1">Name:</strong> | ||
<%= questionnaire.name %> | ||
</p> | ||
|
||
<p class="my-5"> | ||
<strong class="block font-medium mb-1">Available in:</strong> | ||
|
||
<% if questionnaire.available? %> | ||
<span>Open</span> | ||
<% elsif questionnaire.start_date > Time.zone.now %> | ||
<%= time_ago_in_words(questionnaire.start_date) %> | ||
<% else %> | ||
<span>Closed</span> | ||
<% end %> | ||
</p> | ||
<p class="my-5 flex gap-4"> | ||
<strong class="block font-medium mb-1">Manager:</strong> | ||
<%= questionnaire.manager.email_address %> | ||
</p> | ||
|
||
<p class="my-5"> | ||
<strong class="block font-medium mb-1">End date:</strong> | ||
<%= questionnaire.end_date %> | ||
</p> | ||
</div> | ||
<p class="my-5 flex gap-4"> | ||
<strong class="block font-medium mb-1">Name:</strong> | ||
<%= questionnaire.name %> | ||
</p> | ||
|
||
<p class="my-5 flex gap-4"> | ||
<strong class="block font-medium mb-1">Availability:</strong> | ||
<% if questionnaire.available? %> | ||
<span class="text-green-500 font-semibold">Open</span> | ||
<% elsif questionnaire.start_date > Time.zone.now %> | ||
<span class="text-amber-500 font-semibold"><%= time_ago_in_words(questionnaire.start_date) %> until open</span> | ||
<% else %> | ||
<span class="text-red-500 font-semibold">Closed</span> | ||
<% end %> | ||
</p> | ||
|
||
<p class="my-5"> | ||
<strong class="block font-medium mb-1">End Date:</strong> | ||
<%= questionnaire.end_date %> | ||
</p> | ||
</section> | ||
|
||
<% if action_name == "show" %> | ||
<%= button_to "Mark as completed", mark_as_completed_answer_path(params[:id]), method: :post, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" if questionnaire.available? && !@user_questionnaire.completed? %> | ||
<footer> | ||
<% if !Current.user.manager? && questionnaire.available? && !@user_questionnaire.completed? %> | ||
<%= button_to "Mark as completed", | ||
mark_as_completed_answer_path(params[:id]), | ||
method: :post, | ||
class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium", | ||
aria: { label: "Mark questionnaire as completed" } %> | ||
<% end %> | ||
</footer> | ||
<% end %> | ||
|
||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
<% content_for :title, "Editing questionnaire" %> | ||
|
||
<h1>Editing questionnaire</h1> | ||
|
||
<%= render "form", questionnaire: @questionnaire %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this questionnaire", @questionnaire %> | | ||
<%= link_to "Back to questionnaires", questionnaires_path %> | ||
</div> | ||
<section class="container mx-auto px-4"> | ||
<%= turbo_frame_tag "edit_quesitonnaire" do %> | ||
<%= render "form", questionnaire: @questionnaire %> | ||
<% end %> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<% content_for :title, "New questionnaire" %> | ||
|
||
<h1>New questionnaire</h1> | ||
|
||
<%= render "form", questionnaire: @questionnaire %> | ||
<section class="container mx-auto px-4"> | ||
<%= turbo_frame_tag "new_quesitonnaire" do %> | ||
<%= render "form", questionnaire: @questionnaire %> | ||
<% end %> | ||
</section> |