45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
<fieldset class="box tabular">
|
|
<legend>부서 정보</legend>
|
|
|
|
<p>
|
|
<%= f.label :department_type, '부서 유형' %> <span class="required">*</span>
|
|
<%= f.select :department_type, Department::TYPES.map { |k, v| [v, k] }, {}, required: true, id: 'department_type_select' %>
|
|
</p>
|
|
|
|
<p>
|
|
<%= f.label :name, '부서명' %> <span class="required">*</span>
|
|
<%= f.text_field :name, size: 40, required: true %>
|
|
</p>
|
|
|
|
<p id="parent_field">
|
|
<%= f.label :parent_id, '상위 부서' %>
|
|
<%= f.select :parent_id,
|
|
options_from_collection_for_select(@parents, :id, :name, @department.parent_id),
|
|
{ include_blank: '-- 최상위 (대표이사 직속) --' } %>
|
|
</p>
|
|
|
|
<p>
|
|
<%= f.label :description, '설명' %>
|
|
<%= f.text_area :description, rows: 3, cols: 60 %>
|
|
</p>
|
|
</fieldset>
|
|
|
|
<%= javascript_tag do %>
|
|
$(document).ready(function() {
|
|
function updateParentOptions() {
|
|
var type = $('#department_type_select').val();
|
|
var parentField = $('#parent_field');
|
|
|
|
if (type === 'ceo') {
|
|
parentField.hide();
|
|
$('#department_parent_id').val('');
|
|
} else {
|
|
parentField.show();
|
|
}
|
|
}
|
|
|
|
$('#department_type_select').on('change', updateParentOptions);
|
|
updateParentOptions();
|
|
});
|
|
<% end %>
|