310 lines
12 KiB
Plaintext
310 lines
12 KiB
Plaintext
<% @current_user = current_user %>
|
|
<% content_for :page_specific_css do %>
|
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
|
<%= stylesheet_link_tag "lib/fileupload" %>
|
|
<%= stylesheet_link_tag "lib/main-list" %>
|
|
<%= stylesheet_link_tag "select2/select2" %>
|
|
<% end %>
|
|
<% content_for :page_specific_javascript do %>
|
|
<%= javascript_include_tag "select2/select2.min" %>
|
|
<% end %>
|
|
<style type="text/css">
|
|
.file_block{
|
|
display: inline-block;
|
|
}
|
|
.reach_limit{
|
|
background: #a90c0c;
|
|
color: white;
|
|
padding: 4px 12px;
|
|
font-family: 'Varela Round';
|
|
letter-spacing: -.4px;
|
|
cursor: default;
|
|
display: inline-block;
|
|
}
|
|
.add-on.btn-group .dropdown-menu{
|
|
margin: 0;
|
|
}
|
|
.main-forms fieldset .input-area .controls .input-prepend a:hover{
|
|
color: #fff;
|
|
}
|
|
.main-forms fieldset .input-area {
|
|
padding: 0;
|
|
}
|
|
.comment-block .content_textarea{
|
|
display: block;
|
|
width: 80%;
|
|
min-height: 100px;
|
|
}
|
|
.comment-block .content_textarea.hide{
|
|
display: none;
|
|
}
|
|
.comment-block .user_name{
|
|
font-size: 1.5em;
|
|
}
|
|
.comment-block p.content_text{
|
|
background-color: #fff;
|
|
border-radius: 3px;
|
|
box-shadow: 0 1px 2px -1px rgb(9 30 66 / 25%), 0 0 0 1px rgb(9 30 66 / 8%);
|
|
box-sizing: border-box;
|
|
padding: 0.5em;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
max-width: 80%;
|
|
}
|
|
</style>
|
|
<% content_for :page_specific_javascript do %>
|
|
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
|
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
|
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
|
<%= javascript_include_tag "lib/file-type" %>
|
|
<%= javascript_include_tag "lib/module-area" %>
|
|
<%= javascript_include_tag "form" %>
|
|
<% end %>
|
|
<div class="control-group">
|
|
<label class="control-label">*<%= t("ruling_timer.task_name") %></label>
|
|
<div class="controls">
|
|
<%= f.text_field :task_name, :required => "required" %>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.project") %></label>
|
|
<div class="controls">
|
|
<% if params[:project_id] %>
|
|
<%= @project.get_project_name %>
|
|
<% else %>
|
|
<%= f.select :ruling_timer_project_id, options_for_select(@projects.collect{|pj| [pj.get_project_name,(pj.new_record? ? "private_task" : pj.id.to_s)]},f.object.ruling_timer_project_id.to_s), {}, {:id=>"ruling_timer_project_id",:class=>"select2_selection_box"} %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.sections") %></label>
|
|
<div class="controls">
|
|
<%= f.select :ruling_timer_section_id, options_for_select(@project.ruling_timer_sections.collect{|section| [section.section_name,section.id.to_s]},f.object.ruling_timer_section_id.to_s), {:include_blank => true}, {:id=>"ruling_timer_section_id",:class=>"select2_selection_box"} %>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t(:tags) %></label>
|
|
<span class="input-area">
|
|
<%= select_tags(f, @module_app) %>
|
|
</span>
|
|
</div>
|
|
<%= render :partial => "form_opts", :locals => {:base_name=>"ruling_timer",:field_name=>"privacy",:f=>f} %>
|
|
<%= render :partial => "form_opts", :locals => {:base_name=>"ruling_timer",:field_name=>"priority",:f=>f} %>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.owner") %></label>
|
|
<div class="controls">
|
|
<div id="owner_append_area" class="checkbox-card">
|
|
<%= @selected_owners.join("\n").html_safe %>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<button id="add_user_btn" type="button" class="btn btn-primary" data-modal="#owner_modal"><%=t("ruling_timer.change")%></button>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.helper") %></label>
|
|
<div class="controls">
|
|
<div id="helper_append_area" class="checkbox-card">
|
|
<%= @selected_helpers.join("\n").html_safe %>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<button id="add_user_btn" type="button" class="btn btn-primary" data-modal="#helper_modal"><%=t("ruling_timer.add_member")%></button>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.observer") %></label>
|
|
<div class="controls">
|
|
<div id="observer_append_area" class="checkbox-card">
|
|
<%= @selected_observers.join("\n").html_safe %>
|
|
</div>
|
|
<div class="clearfix"></div>
|
|
<button id="add_user_btn" type="button" class="btn btn-primary" data-modal="#observer_modal"><%=t("ruling_timer.add_member")%></button>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.progress") %></label>
|
|
<div class="controls">
|
|
<input type="range" min="0" max="100" value="<%=f.object.progress%>" class="slider" id="task_progress" name="<%=f.object_name%>[progress]"><span><span class="slider_value"><%=f.object.progress%></span>%</span>
|
|
</div>
|
|
</div>
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.details") %></label>
|
|
<div class="controls">
|
|
<%= f.text_area :details, :class=>"ckeditor" %>
|
|
</div>
|
|
</div>
|
|
<!-- Comments -->
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t("ruling_timer.comments") %></label>
|
|
<div class="controls">
|
|
<p class="add-btn">
|
|
<%= hidden_field_tag 'ruling_timer_comment_field_count', f.object.ruling_timer_comments.count %>
|
|
<a id="add_comment" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
|
</p>
|
|
<!-- Add -->
|
|
<div class="add-target">
|
|
</div>
|
|
<!-- Exist -->
|
|
<% if f.object && !f.object.ruling_timer_comments.blank? %>
|
|
<div class="exist">
|
|
<% f.object.ruling_timer_comments.desc(:created_at).each_with_index do |ruling_timer_comment, i| %>
|
|
<%= f.fields_for :ruling_timer_comments, ruling_timer_comment do |f| %>
|
|
<%= render :partial => 'form_comment', :object => ruling_timer_comment, :locals => {:f => f, :i => i} %>
|
|
<% end %>
|
|
<% end %>
|
|
<hr>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
<!-- File -->
|
|
<div class="control-group">
|
|
<label class="control-label muted"><%= t(:file_) %></label>
|
|
<div class="controls">
|
|
<!-- Exist -->
|
|
<% if f.object && !f.object.ruling_timer_files.blank? %>
|
|
<div class="exist">
|
|
<% f.object.ruling_timer_files.each_with_index do |ruling_timer_file, i| %>
|
|
<%= f.fields_for :ruling_timer_files, ruling_timer_file do |f| %>
|
|
<%= render :partial => 'form_file', :object => ruling_timer_file, :locals => {:f => f, :i => i} %>
|
|
<% end %>
|
|
<% end %>
|
|
<hr>
|
|
</div>
|
|
<% end %>
|
|
|
|
<!-- Add -->
|
|
<div class="add-target">
|
|
</div>
|
|
<p class="add-btn">
|
|
<%= hidden_field_tag 'ruling_timer_file_field_count', f.object.ruling_timer_files.count %>
|
|
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
|
</p>
|
|
|
|
</div>
|
|
</div>
|
|
<!-- Form Actions -->
|
|
<div class="form-actions">
|
|
<%= f.hidden_field :time_offset, :id=>"task_timeoffset" %>
|
|
<% referer = request.referer rescue nil %>
|
|
<% referer = get_referer_url if referer.blank? || request.host != URI.parse(URI.encode(referer)).host %>
|
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
|
<input type="hidden" name="referer_url" value="<%= referer %>">
|
|
<%= link_to t('cancel'), referer, :class=>"btn" %>
|
|
</div>
|
|
<script>
|
|
if (!Array.prototype.includes) {
|
|
Object.defineProperty(Array.prototype, "includes", {
|
|
enumerable: false,
|
|
value: function(obj) {
|
|
var newArr = this.filter(function(el) {
|
|
return el == obj;
|
|
});
|
|
return newArr.length > 0;
|
|
}
|
|
});
|
|
}
|
|
function matchCustom(params, data) {
|
|
var all_options = this.element[0].all_options;
|
|
if(params == undefined || params.trim() == ''){
|
|
return all_options.includes(data);
|
|
}else{
|
|
return (data.toLowerCase().search(params.toLowerCase()) != -1)
|
|
}
|
|
}
|
|
var select2 = $(".select2_selection_box");
|
|
var allow_section_relations = <%= @projects.map{|p| [p.id.to_s, p.ruling_timer_sections.map{|s| [s.section_name,s.id.to_s]}]}.to_h.to_json.html_safe %>;
|
|
select2.each(function(i,v){
|
|
var select2_item = $(v);
|
|
var all_options = [];
|
|
var all_values = [];
|
|
select2_item.find("option").each(function(j,option){
|
|
all_options.push($(option).text());
|
|
all_values.push($(option).val());
|
|
});
|
|
select2_item[0].all_options = all_options;
|
|
select2_item[0].all_values = all_values;
|
|
var custom_match = $(v).data("custom-match");
|
|
var match_func = (custom_match ? window[custom_match] : matchCustom );
|
|
select2_item.select2({
|
|
placeholder: select2_item.data("placeholder"),
|
|
matcher: match_func,
|
|
width: 'resolve'
|
|
});
|
|
})
|
|
$("#ruling_timer_project_id").on("change select2:select",function(){
|
|
$("#ruling_timer_section_id").empty();
|
|
var all_options = [""];
|
|
$("#ruling_timer_section_id").html(allow_section_relations[$(this).val()].map(function(v){
|
|
all_options.push(v[0]);
|
|
return (new Option(v[0],v[1])).outerHTML;
|
|
}).join("")).prepend("<option value=\"\"></option>");
|
|
var opts = $("#ruling_timer_section_id").data("select2").opts;
|
|
var custom_match = $(this).data("custom-match");
|
|
var match_func = (custom_match ? window[custom_match] : matchCustom );
|
|
$("#ruling_timer_section_id").select2("destroy").select2({
|
|
placeholder: $(this).data("placeholder"),
|
|
matcher: match_func,
|
|
width: 'resolve'
|
|
});
|
|
})
|
|
window.timer_offset = (new Date().getTimezoneOffset() / -60).toString();
|
|
if(window.timer_offset[0] != "-"){
|
|
window.timer_offset = "+" + window.timer_offset;
|
|
}
|
|
$(document).ready(function(){
|
|
$(".slider").each(function(i,slider){
|
|
var $slider = $(slider);
|
|
var $slider_value = $slider.parent().find(".slider_value");
|
|
$slider.slider({
|
|
min: parseInt($slider.attr("min")),
|
|
max: parseInt($slider.attr("max")),
|
|
slide: function(e, ui) {
|
|
$slider_value.html(ui.value);
|
|
}
|
|
})
|
|
$slider.on("change",function(){
|
|
$slider_value.text($(this).val());
|
|
})
|
|
})
|
|
$("#task_timeoffset").val(window.timer_offset);
|
|
$("[data-modal]").click(function(){
|
|
$($(this).data("modal")).modal("show");
|
|
})
|
|
$(document).on('click', '#add_file', function(){
|
|
var new_id = $(this).prev().attr('value');
|
|
var old_id = new RegExp("new_ruling_timer_files", "g");
|
|
var on = $('.language-nav li.active').index();
|
|
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
|
$(this).prev().attr('value', parseInt(new_id) + 1);
|
|
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :ruling_timer_files) %>").replace(old_id, new_id));
|
|
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
|
|
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
|
|
});
|
|
formTip();
|
|
});
|
|
$(document).on('click', '.delete_file, .delete_comment', function(){
|
|
$(this).parents('.input-prepend,.input-block').remove();
|
|
});
|
|
$(document).on('click', '.remove_existing_record', function(){
|
|
if(confirm("<%= I18n.t(:sure?)%>")){
|
|
$(this).children('.should_destroy').attr('value', 1);
|
|
$(this).parents('.start-line,.comment-block').hide();
|
|
}
|
|
});
|
|
$(document).on('click', '#add_comment', function(){
|
|
var new_id = $(this).prev().attr('value');
|
|
var old_id = new RegExp("new_ruling_timer_files", "g");
|
|
var on = $('.language-nav li.active').index();
|
|
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
|
|
$(this).prev().attr('value', parseInt(new_id) + 1);
|
|
$(this).parent().siblings('.add-target').prepend(("<%= escape_javascript(add_attribute 'form_comment', f, :ruling_timer_comments) %>").replace(old_id, new_id));
|
|
formTip();
|
|
});
|
|
$(".edit_comment").click(function(){
|
|
var comment_block = $(this).parents(".comment-block");
|
|
comment_block.find(".content_text").addClass("hide");
|
|
comment_block.find(".content_textarea").removeClass("hide").focus();
|
|
$(this).addClass("hide");
|
|
})
|
|
})
|
|
</script> |