-
Notifications
You must be signed in to change notification settings - Fork 4k
/
edit.html.erb
111 lines (103 loc) 路 6 KB
/
edit.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
<% title t("views.listings.edit.heading") %>
<header class="crayons-layout crayons-layout--limited-l flex items-center justify-between p-2 l:p-4 l:pb-0">
<h1 class="crayons-title"><%= t("views.listings.edit.heading") %></h1>
</header>
<main class="crayons-layout crayons-layout--2-cols crayons-layout--2-cols--inverted crayons-layout--limited-l">
<div class="crayons-layout__content">
<div class="crayons-card mb-6 p-6">
<%= form_for(@listing, html: { class: "grid gap-6 mb-6" }) do |f| %>
<div class="crayons-notice" aria-live="polite"><%= t("views.listings.edit.notice") %></div>
<%= render partial: "form_errors", locals: { listing: @listing } %>
<% if (@listing.bumped_at && @listing.bumped_at > 24.hours.ago) || @listing.updated_at && !@listing.published %>
<div class="crayons-field">
<%= f.label "title", class: "crayons-field__label" %>
<%= f.text_field "title", maxlength: 128, placeholder: t("views.listings.form.title.placeholder"), class: "crayons-textfield" %>
</div>
<div class="crayons-field">
<%= f.label "body_markdown", class: "crayons-field__label" %>
<%= f.text_area "body_markdown", maxlength: 400, placeholder: t("views.listings.form.body_markdown.placeholder"), class: "crayons-textfield" %>
<p class="crayons-field__description"><%= t("views.listings.form.body_markdown.description") %></p>
</div>
<div class="crayons-field">
<%= f.label "tag_list", class: "crayons-field__label" %>
<%= f.text_field "tag_list", value: @listing.cached_tag_list, placeholder: t("views.listings.form.tags.placeholder"), class: "crayons-textfield" %>
</div>
<div class="crayons-field">
<%= f.label "expires_at", "Custom Expire Date", class: "crayons-field__label" %>
<%= f.date_field "expires_at", min: Date.tomorrow, max: @listing.natural_expiration_date, class: "crayons-textfield m:max-w-50" %>
<p class="crayons-field__description">
<%= t("views.listings.form.expiry.description") %>
</p>
</div>
<div class="crayons-field crayons-field--checkbox">
<%= f.check_box "contact_via_connect", class: "crayons-checkbox" %>
<label class="crayons-field__label" for="contact_via_connect">
<%= t("views.listings.form.connect.subtitle") %>
<p class="crayons-field__description"><%= t("views.listings.form.connect.description") %></p>
</label>
</div>
<div class="crayons-field">
<%= f.label "location", class: "crayons-field__label" %>
<%= f.text_field "location", maxlength: 32, placeholder: t("views.listings.form.location.placeholder"), class: "crayons-textfield m:max-w-50" %>
<p class="crayons-field__description"><%= t("views.listings.form.location.description") %></p>
</div>
<div>
<% if @listing.published %>
<%= f.submit t("views.listings.edit.update"), class: "crayons-btn" %>
<% else %>
<%= f.submit t("views.listings.edit.update_draft"), class: "crayons-btn crayons-btn--secondary" %>
<% end %>
</div>
<% end %>
<% end %>
<%= form_for(@listing, html: { class: "pt-6 mt-6 border-t-1 border-solid border-0 border-base-20 flex items-center" }) do |f| %>
<% if @listing.published == false %>
<input type="hidden" name="listing[action]" value="publish" />
<%= f.submit t("views.listings.edit.publish"), class: "crayons-btn mr-4" %>
<p><%= t("views.listings.edit.not_published.text_html", not: tag.strong(t("views.listings.edit.not_published.not"), class: "color-accent-danger")) %></p>
<% else %>
<input type="hidden" name="listing[action]" value="unpublish" />
<%= f.submit t("views.listings.edit.unpublish"), class: "crayons-btn crayons-btn--danger" %>
<% end %>
<% end %>
</div>
<% if @listing.bumped_at %>
<%= form_for(@listing, html: { class: "crayons-card grid gap-6 p-6 mb-6" }) do |f| %>
<header>
<h2 class="mb-2"><%= t("views.listings.edit.bump.subtitle") %></h2>
<p><%= t("views.listings.edit.bump.description") %></p>
</header>
<div class="flex items-center">
<%= f.submit t("views.listings.edit.bump.button"), class: "crayons-btn crayons-btn--secondary mr-4" %>
<p class="color-base-70"><%= t("views.listings.edit.bump.last", date: time_ago_in_words(@listing.bumped_at, scope: :'datetime.distance_in_words_ago')) %></p>
</div>
<input type="hidden" name="listing[action]" value="bump" />
<% end %>
<% end %>
</div>
<aside class="crayons-layout__sidebar-right px-3 m:px-0">
<% unless @listing.published %>
<%= form_for(@listing, html: { class: "crayons-card crayons-card--secondary p-3 m:p-4 mb-2 m:mb-4" }) do |f| %>
<p class="pb-4">
<%= t("views.listings.edit.not_published.aside_html", not: tag.strong(t("views.listings.edit.not_published.not"), class: "color-accent-danger")) %>
</p>
<input type="hidden" name="listing[action]" value="publish" />
<%= f.submit t("views.listings.edit.publish"), class: "crayons-btn w-100" %>
<% end %>
<% end %>
<div class="crayons-card crayons-card--secondary p-3 m:p-4 mb-2 m:mb-4">
<p>
<% if (@listing.natural_expiration_date) < Date.today %>
<%= time_ago_in_words @listing.natural_expiration_date, scope: :"datetime.expired_ago" %>
<% else %>
<%= time_ago_in_words @listing.natural_expiration_date, scope: :"datetime.expires_in" %>
<% end %>
</p>
<% if @listing.bumped_at %>
<p class="pt-3 mt-3 border-t-1 border-solid border-0 border-base-10">
<%= t("views.listings.edit.bump.last", date: time_ago_in_words(@listing.bumped_at, scope: :"datetime.distance_in_words_ago")) %>
</p>
<% end %>
</div>
</aside>
</main>