This repository has been archived by the owner on Oct 12, 2018. It is now read-only.
/
_form.html.erb
114 lines (91 loc) · 4.92 KB
/
_form.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<% if flash[:notice].present? %>
<div class="alert alert-success"><%= flash[:notice] %></div>
<% end %>
<% if artefact.errors.count > 0 %>
<div class="alert alert-error">
<ul>
<% artefact.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% if artefact.archived? %>
<div class="alert alert-error">
<h2>Stop! You can't edit this artefact because it has been archived.</h2>
</div>
<% else %>
<div class="well">
<%= semantic_form_for(artefact, :html => { :class => '', :id => 'edit_artefact'}) do |f| %>
<%= f.inputs do %>
<%= f.input :name, :input_html => { :class => "span6", :disabled => f.object.persisted?}, :hint => name_hint_for(f.object) %>
<%= f.input :description, :input_html => { :class => "span6", :disabled => true, :rows => 6 }, :hint => 'Managed through API and/or owning app', :as => :text %>
<%= f.input :slug, :input_html => { :class => "span6", :disabled => f.object.live? }, :hint => "A valid slug might look like this: i-am-a-good-slug-with-no-spaces" %>
<%= f.input :need_id, :input_html => { :class => "span6", :disabled => f.object.persisted? } %>
<% if ! artefact.new_record? && ! artefact.business_proposition %>
<%= link_to "View in Need-O-Tron", need_url(f.object), :rel => 'external', :class => "btn btn-primary" %>
<% end %>
<%= link_to "View on site", published_url(f.object), :rel => 'external', :class => "btn btn-primary" unless f.object.new_record? %>
<hr>
<%= f.input :language, :collection => {"English" => "en", "Welsh" => "cy"}, :as => :select, :input_html => { :class => "span2" }, :include_blank => false %>
<%= f.input :business_proposition, :label => 'Is this business content?', :as => :boolean %>
<hr>
<input type="hidden" name="artefact[sections][]" value="" />
<% if artefact.new_record? %>
<%= f.input :kind, :collection => non_whitehall_formats.map { |s| [s.humanize, s]}, :as => :select, :class => "span6", :prompt => "Select a kind" %>
<% end %>
<label for="artefact[sections][]">Sections</label>
<p>The first section will be the primary section the content lives in. This will form the content breadcrumb.</p>
<% if artefact.section_ids.length > 0 %>
<% artefact.section_ids.each do | section_id | %>
<%= render :partial => 'artefact_section', :locals => {:section_id => section_id, :tag_collection => tag_collection} %>
<% end %>
<% else %>
<%= render :partial => 'artefact_section', :locals => {:section_id => nil, :tag_collection => tag_collection} %>
<% end %>
<button id="add-section" class="btn btn-success" type="button">Add another section</button>
<% end %>
<hr>
<%= f.inputs do %>
<label for="artefact[related_artefact_ids][]">Related content</label>
<p>Click and drag to reorder</p>
<div class="related-artefact-group">
<% if artefact.related_artefact_ids.length > 0 %>
<% artefact.related_artefact_ids.each do |related_artefact_id| %>
<%= render :partial => 'related_artefact', :locals => { related_artefact_id: related_artefact_id, is_template: false } %>
<% end %>
<% else %>
<%= render :partial => 'related_artefact', :locals => { related_artefact_id: nil, is_template: false } %>
<% end %>
</div>
<%= render :partial => 'related_artefact', :locals => { related_artefact_id: nil, is_template: true } %>
<button id="add-related" class="btn btn-success" type="button">Add another related item</button>
<%= f.input :relatedness_done, :label => "Is relatedness done?", :as => :boolean %>
<% end %>
<hr>
<%= f.input :legacy_source_ids, :label => "Legacy sources", :collection => options_for_tags_of_type('legacy_source'), :input_html => { :multiple => true, :class => "span6 chzn-select" } %>
<hr>
<%= f.inputs do %>
<%= f.input :department, :label => "Writing team", :input_html => { :disabled => f.object.persisted?, :class => "span6"} %>
<%= f.input :fact_checkers, :input_html => { :disabled => f.object.persisted?, :class => "span6"} %>
<% end %>
<% if artefact.new_record? %>
<%= f.input :owning_app, :as => :hidden, :input_html => {:value => "publisher"} %>
<% end %>
<hr>
<% if f.object.persisted? %>
<%= f.submit :value => "Save and continue editing", :class => "btn" %>
<% end %>
<%= f.submit :value => "Save and go to item", :class => "btn btn-success" %>
<% end %>
</div>
<% end %>
<%= content_for :extra_javascript do %>
<script type="text/javascript">
$(".chzn-select").chosen();
$('.related-artefact-group').sortable();
if ($('.artefact-section').size() == 1) {
$('.remove-section').hide();
}
</script>
<% end %>