This repository has been archived by the owner on Oct 12, 2018. It is now read-only.
/
_form.html.erb
99 lines (80 loc) · 4.2 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
<% 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" } %>
<%= 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 :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 => Artefact::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">Add another section</button>
<% end %>
<hr>
<%= f.inputs do %>
<input name="artefact[related_artefact_ids][]" type="hidden" value="">
<%= f.input :related_artefacts, :label => "Related content", :collection => Artefact.in_alphabetical_order, :input_html => { :multiple => true, :class => "span6 chzn-select" }, :hint => "Start typing in to search for and select related links to be associated with this." %>
<%= 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"} %>
<%= f.input :contact, :as => :hidden, :collection => Contact.in_alphabetical_order %>
<% 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 %>
<%= javascript_include_tag('chosen.jquery.min.js', 'artefacts') %>
<script type="text/javascript">
$(".chzn-select").chosen();
if ($('.artefact-section').size() == 1) {
$('.remove-section').hide();
}
</script>
<% end %>
<% content_for :extra_headers, stylesheet_link_tag('chosen') %>