From d48adb741c5c30ba3f2d3c039a7e342b43add352 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Jul 2018 10:42:21 -0400 Subject: Added blog drafts An unpublished post is not viewable unless you are logged in. The "Create record" field is disabled for unpublished posts, though this is only in JavaScript and the backend will not disallow creating records for unpublished posts if forced to. Unpublishing a post does not destroy records for that post. This only applies to blog posts, currently; streams and stream updates cannot be drafted. Unpublished posts still require titles and slugs. There is no autosaving functionality yet. refs #1 --- app/assets/javascripts/admin/records.coffee | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/admin/records.coffee b/app/assets/javascripts/admin/records.coffee index 69cd471..3a1ed51 100644 --- a/app/assets/javascripts/admin/records.coffee +++ b/app/assets/javascripts/admin/records.coffee @@ -1,9 +1,25 @@ # Place all the behaviors and hooks related to the matching controller here. # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ + +create_record_toggle = (checked) -> + if checked + $(".record-description-field").show() + else + $(".record-description-field").hide() + +published_field_toggle = (checked) -> + if checked + $(".should-create-record-field input[type=checkbox]").prop("disabled", false) + else + $(".should-create-record-field input[type=checkbox]").prop("disabled", true) + $(".should-create-record-field input[type=checkbox]").prop("checked", false) + create_record_toggle(false) + $(document).on "turbolinks:load", -> + if $(".published-field").length > 0 + published_field_toggle($(".published-field input[type=checkbox]").prop("checked")) $(".should-create-record-field input[type=checkbox]").change -> - if $(".should-create-record-field input[type=checkbox]").prop("checked") - $(".record-description-field").show() - else - $(".record-description-field").hide() + create_record_toggle($(this).prop("checked")) + $(".published-field input[type=checkbox]").change -> + published_field_toggle($(this).prop("checked")) -- cgit 1.4.1