Newer
Older
dmpopidor / app / views / guidances / admin_edit.html.erb
<%= stylesheet_link_tag "admin" %>
<% javascript 'admin.js' %>

<h1>
	<%= t('org_admin.guidance_label') %>
	<!-- link button to add new guidance -->
	<div class="move_2_right">
		<%= link_to t("org_admin.guidance.add_guidance"),
		            admin_new_guidance_path,
		            :class => 'btn btn-primary' %>
		<%= link_to t("org_admin.guidance.view_all_guidance"),
		            admin_index_guidance_path,
		            :class => 'btn btn-primary' %>
	</div>            
</h1>

<div class="div_clear"></div>

<div class="white_background blue_border">
	<!-- body -->
	<div class="dmp_details">
		<%= form_for(@guidance, :url => admin_update_guidance_path(@guidance), :html => { :method => :put , :id => 'edit_guidance_form'}) do |f| %>
			
				<table class="dmp_details_table guidance_table">
					<tr>
						<td class="first"><%= t('org_admin.guidance.text_label') %></td>
						<td><div class="div_left_icon_g">
								<%= text_area_tag("guidance-text", @guidance.text, class: "tinymce") %>
							</div>
							<div class="div_right_icon_g">
								<%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_text_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance.text_help_text_html'))%>
							</div>
							<div class="clearfix"></div>
						</td>
					</tr>
					<tr>
						<td class="first"><%= t('org_admin.guidance.by_theme_or_by_question') %></td>
						<td><div class="div_left_icon_g">
								<% if !@guidance.question_id.nil? then %>
									<% select_op = 2 %>
								<% else%>
									<% select_op = 1%>
								<%end%>
								<%= hidden_field 'select_op' , :value => select_op,  :id => 'edit_guid_ques_flag' %>
								
								<%= select_tag "g_options", options_for_select({t('org_admin.guidance.by_themes_label') => 1, 
									t('org_admin.guidance.by_question_label') => 2}, select_op) %>
							</div>
							<div class="div_right_icon_g">
								<%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_apply_to_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance.apply_to_help_text_html'))%>
							</div>
							<div class="clearfix"></div>
							
							
							<div class="guindance_by_theme" style="display:none;"> 
								<div class="div_left_icon_g">
									<%= f.collection_select(:theme_ids,
									Theme.all.order('title'),
									:id, :title, {:prompt => false, :include_blank => 'None'}, {:multiple => true})%>
								</div>
								<div class="div_right_icon_g">
									<%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_by_themes_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance.by_themes_help_text_html'))%>
								</div>
								<div class="clearfix"></div>
								
							</div>	
							<div class="guindace_by_question" style="display:none;">
								<div class="div_left_icon_g">
									<% if !@guidance.question_id.nil? then %>
										<% dmp_template_id = @guidance.question.section.version.phase.dmptemplate_id %>
										<% phase_id = @guidance.question.section.version.phase_id %>
										<% version_id = @guidance.question.section.version_id %>
										<% section_id = @guidance.question.section_id %>

										<%= collection_select(:phase, :dmptemplate_id,  Dmptemplate.all.order('title'), :id, :title, {:prompt   => "Select a template", :selected =>  dmp_template_id}, {:id => 'templates_select'}) %>

										<br/>
										<%= collection_select(:version, :phase_id, Phase.where("dmptemplate_id = ?", dmp_template_id).order('title ASC'), :id, :title, {:prompt => I18n.t('helpers.select_phase'), :selected =>  phase_id}, {:id => 'phases_select'}) %>
										<br/>
										<%= collection_select(:section, :version_id, Version.where("phase_id = ?", phase_id).order('title ASC'), :id, :title, {:prompt   => I18n.t('helpers.select_version'), :selected =>  version_id}, {:id => 'versions_select'}) %>
		 								<br/>
										<%= collection_select(:question, :section_id, Section.where("version_id = ?", version_id).order('title ASC'), :id, :title, {:prompt   => I18n.t('helpers.select_section'), :selected =>  section_id }, {:id => 'sections_select'}) %>
										<br/>
										<%= collection_select(:guidance, :question_id, Question.where("section_id = ?", section_id).order('text ASC'), :id, :text, {:prompt   => I18n.t('helpers.select_question')}, {:id => 'questions_select'}) %>
		 							<%else%>
		 								<%= collection_select(nil, :dmptemplate_id,  @dmptemplates, :id, :title, {:prompt   => I18n.t('helpers.select_template')}, {:id => 'templates_select'}) %>
										<br/>
										<%= collection_select(nil, :phase_id, @phases, :id, :title, {:prompt   => I18n.t('helpers.select_phase')}, {:id => 'phases_select'}) %>
										<br/>
										<%= collection_select(nil, :version_id, @versions, :id, :title, {:prompt   => I18n.t('helpers.select_version')}, {:id => 'versions_select'}) %>
		 								<br/>
										<%= collection_select(nil, :section_id, @sections, :id, :title, {:prompt   => I18n.t('helpers.select_section')}, {:id => 'sections_select'}) %>
										<br/>
										<%= collection_select(nil, :question_id, @questions, :id, :text, {:prompt   => I18n.t('helpers.select_question')}, {:id => 'questions_select'}) %>
		  							<%end%>
		  						</div>
								<div class="div_right_icon_g">
									<%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_by_question_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance.by_question_help_text_html'))%>
								</div>
								<div class="clearfix"></div>	
							</div>	
						</td>
					
					</tr>
                    <tr>
                        <td class="first"><%= t('org_admin.guidance.published') %></td>
                        <td><div class="div_left_icon_g">
                                <%= f.check_box :published , :as => :check_boxes%> 
                            </div>
                            <div class="div_right_icon_g">
                                <!--%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_group_subset_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance_group.subset_option_help_text'))%-->
                            </div>
                        </td>
                    </tr>
					<tr>
						<td class="first"><%= t('org_admin.guidance.guidance_group_label') %></td>
						<td><div class="div_left_icon_g">
                                <%= f.collection_select(:guidance_group_ids,
								GuidanceGroup.where("organisation_id = ?", current_user.organisation_id).order('name ASC'),
								:id, :name, {:prompt => false, :include_blank => 'None'}, {:multiple => false})%>
							</div>
							<div class="div_right_icon_g">
								<%= link_to( image_tag('help_button.png'), '#', :class => 'guidance_group_select_popover', :rel => "popover", 'data-html' => "true", 'data-content' => t('org_admin.guidance.guidance_group_select_help_text_html'))%>
							</div>
							<div class="clearfix"></div>
							
						</td>
					</tr>
					
				</table>
			
			<!-- submit buttons -->
			
				<div class="move_2_right">
                    <a id="edit_guidance_submit" data-toggle="modal" href="#edit_guidance_alert_dialog" class="btn btn-primary"><%= t('helpers.submit.save')%></a>
                    <%= link_to t('helpers.submit.cancel'), :back, :class => 'btn cancel' %>
				</div>
			
			<br />
			<%= tinymce :content_css => asset_path('application.css') %>
		<%end%>
	</div>
</div>	


<!-- alert for the default template-->
<div id="edit_guidance_alert_dialog" data-container="body" data-backdrop="static" class="modal hide fade">
	<div class="modal-header">
		<h3><%= t('helpers.before_submitting_consider') %></h3>
	</div>
	<div class="modal-body">
		<ul id="missing_fields_edit_guidance"></ul>
  	</div>
	<div class="modal-footer">
    	<a href="#" id="return_to_edit_guidance" class="btn"><%= t('helpers.ok_label') %></a>
    </div>
</div>