<%= form_for(@work, html: { id: "work-form", class: "verbose post work" }) do |f| %>

* <%= ts("Required information") %>

<%= render "work_form_tags", include_blank: false %>
<%= t("works.preface.title") %>

<%= t("works.preface.title") %>

<%= f.label :title, ts("Work Title") + "*" %>
<%= f.text_field :title, class: "observe_textlength text" %> <%= live_validation_for_field("work_title", maximum_length: ArchiveConfig.TITLE_MAX, minimum_length: ArchiveConfig.TITLE_MIN, failureMessage: ts("We need a title! (At least %{min_length} character long, please.)", min_length: ArchiveConfig.TITLE_MIN.to_s)) %> <%= generate_countdown_html("work_title", ArchiveConfig.TITLE_MAX) %>
<%= render "pseuds/byline", form: f, object: @work %>
<%= f.label :summary, ts("Summary", max: ArchiveConfig.SUMMARY_MAX.to_s) %>
<%= f.text_area :summary, class: "observe_textlength" %> <%= live_validation_for_field("work_summary", presence: false, maximum_length: ArchiveConfig.SUMMARY_MAX) %> <%= generate_countdown_html("work_summary", ArchiveConfig.SUMMARY_MAX) %>
<%= render "notes_form", f: f, type: "work" %>
<%= t("works.associations.title") %>

<%= t("works.associations.title") %>

<% @assignments = get_open_assignments(current_user) %> <% if @assignments.any? || @work.challenge_assignments.any? %>
<%= f.label "challenge_assignment_ids[]", ts("Does this fulfill a challenge assignment") %> <%= link_to_help "add-work-to-assignment" %>

<%= ts("Open Assignments") %>

<%= checkbox_section f, :challenge_assignment_ids, (@work.challenge_assignments + @assignments).uniq, :checked_method => "challenge_assignments", :name_method => "title" %>
<% end %> <% if !(@claims = current_user.request_claims.unstarted).empty? || !@work.challenge_claims.empty? %>
<%= f.label "challenge_claim_ids[]", ts("Fulfill a Claim") %> <%= link_to_help "add-work-to-assignment" %>

<%= ts("Open Claims") %>

<%= checkbox_section f, :challenge_claim_ids, (@work.challenge_claims + @claims).uniq, :checked_method => "challenge_claims", :name_helper_method => "claim_title" %>
<% end %>
"> <%= f.label :collection_names, ts("Post to Collections / Challenges") %> <%= link_to_help "add-collectible-to-collection" %>
"> <%= f.text_field :collection_names, autocomplete_options("open_collection_names") %>
"> <%= f.label :recipients, ts("Gift this work to") %> <%= link_to_help "recipients" %>
"> <%= f.text_field :recipients, autocomplete_options("pseud", value: @work.recipients(for_form = true)) %>
<%= check_box_tag "parent-options-show", "1", check_parent_box(@work), class: "toggle_formfield" %>
<%= label_tag "parent-options-show", ts("This work is a remix, a translation, a podfic, or was inspired by another work") %> <%= link_to_help "parent-works-help" %>
<% new_parent, existing_parents = @work.parent_work_relationships.partition(&:new_record?) %> <% new_parent << @work.parent_work_relationships.build if new_parent.empty? %> <%= f.fields_for :parent_work_relationships, new_parent do |p| %>
<%= p.label :url, ts("URL") %>
<%= p.text_field :url, "aria-describedby" => "parent-attributes-url-field-description" %>

<%= ts("For a work in the Archive, only the URL is required.") %>

<%= p.label :title %>
<%= p.text_field :title %>
<%= p.label :author %>
<%= p.text_field :author %>
<%= p.label :language_id, ts("Language") %> <%= link_to_help "languages-help" %>
<%= p.select(:language_id, language_options_for_select(sorted_languages, "id"), prompt: " ") %>
<%= p.check_box :translation %>
<%= p.label :translation, ts("This is a translation") %> <%= link_to_help "translation-link" %>
<% end %> <% unless existing_parents.blank? %>
<%= ts("Current parent works") %>
<% existing_parents.each do |related_work| %> <% if related_work.parent %>
<% end %> <% end %> <% end %>
<%= check_box_tag "series-options-show", "1", check_series_box(@work), class: "toggle_formfield" %>
<%= label_tag "series-options-show", ts("This work is part of a series") %> <%= link_to_help "choosing-series" %>
<%= fields_for "work[series_attributes]" do |s| %>
<%= s.label "id", ts("Choose one of your existing series:") %>
<%= s.collection_select(:id, @series, :id, :title, { selected: work_series_value(:id), prompt: true }) %>
<%= s.label :title, ts("Or create and use a new one:") %>
<%= s.text_field :title, value: work_series_value(:title) %>
<% end %> <% unless @serial_works.blank? || @work.new_record? %>
<%= ts("Current Series") %>
<% for serial in @serial_works %> <% unless serial.new_record? %>
<% end %> <% end %> <% end %>
<%= fields_for "work[chapter_attributes]", @chapter do |c| %>
<%= check_box_tag "chapters-options-show", "1", @work.chaptered?, class: "toggle_formfield" %>
<%= label_tag "chapters-options-show", ts("This work has multiple chapters") %>
<%= f.label :wip_length, ts("Chapter 1 of") %>
<%= f.text_field :wip_length, class: "number" %>
<%= c.label :title, ts("Chapter Title:") %>
<%= c.text_field :title, value: @chapter.title %>
<%= f.check_box :backdate, { id: "backdate-options-show", class: "toggle_formfield" } %>
<%= label_tag "backdate-options-show", ts("Set a different publication date") %> <%= link_to_help "backdating-help" %>
<%= label_tag "published_at", ts("Set publication date") %>
"> <%= c.date_select("published_at", :start_year => Date.current.year, :end_year => 1950, :default => Date.current, :value => @chapter.published_at, :order => [:day, :month, :year]) %>
<%= render "work_form_associations_language", f: f %>
<%= f.label :work_skin_id, t("works.skin.select") %> <%= link_to_help "work-skins" %>
<%= f.collection_select :work_skin_id, all_coauthor_skins, :id, :title, { :selected => (@work.work_skin ? @work.work_skin.id.to_s : nil), include_blank: true } %>
<%= t("works.permissions.privacy") %>

<%= t("works.permissions.privacy") %>

<%= f.check_box :restricted %>
<%= f.label :restricted, t("works.permissions.visibility.restricted") %> <%= link_to_help "registered-users" %>
<%= f.check_box :moderated_commenting_enabled %>
<%= f.label :moderated_commenting_enabled, t("comments.commentable.permissions.moderated_commenting.enable") %> <%= link_to_help "comments-moderated" %>
<%= t("comments.commentable.permissions.options.label") %> <%= link_to_help "who-can-comment-on-this-work" %>
<%= radio_button_list(f, :comment_permissions, [ [:enable_all, t("comments.commentable.permissions.options.enable_all")], [:disable_anon, t("comments.commentable.permissions.options.disable_anon")], [:disable_all, t("comments.commentable.permissions.options.disable_all")] ]) %>
<% unless @chapters %>
<%= ts("Work Text") %>*

<%= allowed_html_instructions %>

<%= ts("Note: Text entered in the posting form is not automatically saved. Always keep a backup copy of your work.").html_safe %>

<% use_tinymce %>

<%= ts("Work Text") %>*

<%= c.text_area :content, value: @chapter.content, class: "mce-editor observe_textlength large", id: "content" %> <%= live_validation_for_field("content", maximum_length: ArchiveConfig.CONTENT_MAX_DISPLAYED, minimum_length: ArchiveConfig.CONTENT_MIN, tooLongMessage: ts("We salute your ambition! But sadly the content must be less than %{max} characters long. (Maybe you want to create a multi-chaptered work?)", max: ArchiveConfig.CONTENT_MAX_DISPLAYED.to_s), tooShortMessage: ts("Brevity is the soul of wit, but your content does have to be at least %{min} characters long.", min: ArchiveConfig.CONTENT_MIN.to_s), failureMessage: ts("Brevity is the soul of wit, but your content does have to be at least %{min} characters long.", min: ArchiveConfig.CONTENT_MIN.to_s)) %> <%= generate_countdown_html("content", ArchiveConfig.CONTENT_MAX_DISPLAYED) %>
<% end %> <% end %>
<%= ts("Post") %>

<%= t(".post_notice_html", content_policy_link: link_to(t(".content_policy"), content_path), tos_faq_link: link_to(t(".tos_faq"), tos_faq_path(anchor: "content_faq"))) %>

<% end %> <%= content_for :footer_js do %> <%= javascript_tag do %> $j(document).ready(function(){ $j(".toggle_formfield").click(function() { var targetId = $j(this).attr("id").replace("-show", ""); toggleFormField(targetId); }); }) <% end %> <% end %>