Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add JS for new admin layout/News views (#931)
* Update structure.sql * Revert "Update structure.sql" This reverts commit 682e2d8. * commit * index * Update edit.html.haml * Create blogs.js * Update blogs.js * public image * update * form * js * js * Update binx_admin.js * Update edit.html.haml * Update _public_image.html.haml * change to haml * Update blogs.js * ahh * Fix? * mmmm * Update _public_image.html.erb * Update _public_image.html.erb * Update _public_image.html.erb * revert * create new partial * revert * revert * Add blueimp and script-loader * Update admin_application.js * revert * eh? * working on js * woof * eh * remove blueimp, add filepond * commit * Filepond working, drag and drop working, fixing image preview now * I'm sure there's a better way to do this, but for now I am doing what works * commit * more filepond * commit * remove filepond * What's uppy * ahhhhhh * deleter * beep * commit * Heyyyyoooooo testing works * re-add binxadminblogs to binxadmin * eep * spacing * final? * commit * Update application_css.scss * commit again * add progress bar styles * listicles js * commit * Error fixed/duplicates removed/scss moved to correct place * ope * remove listicle js * js for toggling radio buttons * Styling and rendering public images for admin blogs (#1061) * styling * commit * commit * commit * commit * working? * new page styles * Remove commented out html * listicle fixing, controller changes, refactor js * commit * done * commit * indent * commit * remove excess line * remove template variable, return string * Admin custom layouts revision (#1075) * remove excess line * Revert "remove excess line" This reverts commit 2cc30ed. * WIP * revised * reading over * ahhh why * commit * refactor public image partial * minor * hoooo boy * commit * css hide for custom layouts * hm * minor
- Loading branch information
1 parent
a4352dd
commit a44e63e
Showing
24 changed files
with
774 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/controllers/admin/organizations/custom_layouts_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import log from "../../utils/log"; | ||
|
||
function BinxAdminBlogs() { | ||
return { | ||
init() { | ||
this.editDate() | ||
this.setIndexImage(); | ||
this.setIndex(); | ||
this.noPrimaryPhotoToggle(); | ||
this.publicImageDelete(); | ||
}, | ||
|
||
editDate() { | ||
$("#change_published_date").on("click", e => { | ||
e.preventDefault(); | ||
$("#blog-date").slideDown() | ||
}) | ||
}, | ||
|
||
publicImageDelete() { | ||
$('ul#public_images').on('click', ".image-delete-button", function(e) { | ||
e.preventDefault(); | ||
const id = $(".image-delete-button").closest(".row").find("input").val() | ||
$.ajax({ | ||
url: `/public_images/${id}`, | ||
type: 'delete' | ||
}); | ||
this.closest('li').remove() | ||
}) | ||
}, | ||
|
||
noPrimaryPhotoToggle() { | ||
const noPrimaryPhotoBox = $(".index_image_0") | ||
noPrimaryPhotoBox.on("change", e => { | ||
if (noPrimaryPhotoBox.prop("checked")) { | ||
$(".index-image-select input").prop("checked", false) | ||
} | ||
}) | ||
}, | ||
|
||
setIndex() { | ||
const index_image = $('#blog_index_image_id').val() | ||
return $("li#" + index_image).find($("input")).prop("checked", true) | ||
}, | ||
|
||
setIndexImage(e) { | ||
$("ul#public_images").on("change", '.index-image-select input', function(e) { | ||
e.preventDefault(); | ||
if ($('#blog_index_image_id').val != 0) { | ||
$('#blog_index_image_id').val($(e.target).val()); | ||
$(".index_image_0").prop("checked", false) | ||
} | ||
}) | ||
}, | ||
}; | ||
} | ||
|
||
|
||
export default BinxAdminBlogs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import log from "../../utils/log"; | ||
|
||
// required for uppy file upload | ||
import 'es6-promise/auto' | ||
import 'whatwg-fetch' | ||
require('@uppy/core/dist/style.css') | ||
require('@uppy/dashboard/dist/style.css') | ||
window.Uppy = require('@uppy/core') | ||
window.XHRUpload = require('@uppy/xhr-upload') | ||
window.Dashboard = require('@uppy/dashboard') | ||
window.DragDrop = require('@uppy/drag-drop') | ||
window.Tus = require("@uppy/tus") | ||
window.ProgressBar = require("@uppy/progress-bar") | ||
window.FileInput = require('@uppy/file-input') | ||
window.Form = require("@uppy/form") | ||
|
||
|
||
|
||
function BinxAdminImageUploader() { | ||
return { | ||
init() { | ||
this.uppyFileUpload(); | ||
}, | ||
|
||
uppyFileUpload() { | ||
const uppyOne = new Uppy({ | ||
debug: true, | ||
autoProceed: true | ||
}) | ||
uppyOne | ||
.use(FileInput, { | ||
target: ".UppyForm", | ||
inputName: "public_image[image]" | ||
}) | ||
.use(XHRUpload, { | ||
endpoint: "/public_images", | ||
formData: true, | ||
fieldName: "file", | ||
method: "post" | ||
}) | ||
.use(Dashboard, { | ||
target: '.UppyDragDrop-One', | ||
inline: true | ||
}) | ||
.use(ProgressBar, { | ||
target: '.UppyDragDrop-One-Progress', | ||
hideAfterFinish: false | ||
}) | ||
uppyOne.use(Form, { | ||
target: "#new_public_image", | ||
getMetaFromForm: true, | ||
addResultToForm: true, | ||
multipleResults: false, | ||
submitOnSuccess: false, | ||
triggerUploadOnSubmit: false | ||
}) | ||
uppy.on('upload-success', (file, response) => { | ||
$("ul#public_images").append(this.publicImageTemplate(response.body.public_image)) | ||
}) | ||
}, | ||
|
||
publicImageTemplate(image) { | ||
const alt = image.name | ||
const src = image.image.url | ||
const id = image.id | ||
return `<li> | ||
<div class='card bg-light admin-public-image'> | ||
<div class='card-body'> | ||
<div class='row'> | ||
<div class='col-md-2 col-sm-6 mt-auto'> | ||
<p> | ||
${alt} | ||
</p> | ||
</div> | ||
<div class='col-md-8 col-sm-6 mt-auto'> | ||
<textarea class='form-control'> <img class='post-image' src='${src}' alt='ENTER YOUR TEXT HERE'> </textarea> | ||
</div> | ||
<div class='col-md-2 col-sm-12'> | ||
<div class='img-box'> | ||
<img src='${src}' alt='${alt}'/> | ||
</div> | ||
</div> | ||
</div> | ||
<hr/> | ||
<div class='row mt-2'> | ||
<div class='col-md-2'> | ||
<a href='#' class="image-delete-button"> Delete</a> | ||
</div> | ||
<div class='col-md-8'> | ||
<span> Copy the above text and paste it where you'd like it to appear in the post </span> | ||
</div> | ||
<div class='col-md-2'> | ||
<div class="index-image-select"> | ||
<input class="index_image_${id}" name="index_image_id" type="radio" value="${id}"></input> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</li>` | ||
} | ||
}; | ||
} | ||
|
||
|
||
export default BinxAdminImageUploader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.blog-field | ||
= f.text_area :body, placeholder: "Blog post (in markdown)", rows: 20 | ||
.form-group | ||
= f.text_area :body, placeholder: "Blog post (in markdown)", rows: 20, class: "form-control" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
.listicle-block.row-fluid | ||
%fieldset.well | ||
.span10 | ||
.blog-field | ||
= f.text_field :title, placeholder: 'Title', class: 'form-control' | ||
.blog-field | ||
= f.text_area :body, placeholder: 'Body content - HTML or Markdown', class: 'form-control' | ||
.blog-field | ||
= f.text_field :image_credits, placeholder: 'Image credits - should be a link in HTML or Markdown', class: 'form-control' | ||
.span2{ class: "page_number_#{f.object.list_order}"} | ||
.listicle-image-input | ||
= f.file_field :image | ||
%span.min-width-notice | ||
.card.bg-light.mt-2 | ||
.card-body | ||
.row | ||
.col-md-6 | ||
.form-group | ||
= f.label "Title" | ||
= f.text_field :title, placeholder: 'Title', class: 'form-control' | ||
.col-md-6 | ||
.form-group | ||
= f.label "Credits" | ||
= f.text_field :image_credits, placeholder: 'Image credits - should be a link in HTML or Markdown', class: 'form-control' | ||
.row | ||
.col-md-12 | ||
.form-group | ||
= f.label "Body" | ||
= f.text_area :body, placeholder: 'Body content - HTML or Markdown', class: 'form-control' | ||
.row | ||
.col-md-6 | ||
.form-group | ||
= f.file_field :image | ||
%span | ||
min-width 726px | ||
%label.index-image-select | ||
<input type="radio" name="index_image_id" value="#{f.object.id}" class="index_image_#{f.object.id}"> | ||
Primary image | ||
.list-order | ||
%label.index-image-select | ||
<input type="radio" name="index_image_id" value="#{f.object.id}" class="index_image_#{f.object.id}"> | ||
Primary image | ||
.col-md-6 | ||
%span | ||
Order | ||
= f.number_field :list_order, placeholder: '1', min: 0, class: 'form-control' | ||
%span.current-count | ||
= f.hidden_field :_destroy, class: 'remove-listicle-block' | ||
.form-group | ||
= f.number_field :list_order, placeholder: '1', min: 0, class: 'form-control' | ||
= f.hidden_field :_destroy | ||
|
||
|
||
|
||
%a.remove_fields | ||
Remove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.