Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COR-217: Content Publishable #341

Merged
merged 17 commits into from
Sep 26, 2016
Merged

Conversation

ElliottAYoung
Copy link
Contributor

@arelia @toastercup

Paired with @arelia on this one

Adds the publishable attribute to the ContentType field so that ContentTypes can be dynamically flagged to be publishable or not. From there we have created the PublishState table to create and update the publish state and all relevant metadata for all ContentItems where publishable is set to true. We have adjusted the buttons on the form to be set based on the current PublishState of the ContentItem and have extracted these into cells. PublishState is now actually retrievable on the Index using the #get_publish_state method on the ContentItem model.

private

def render_edit
link_to "<i class='material-icons'>create</i>".html_safe, edit_content_type_content_item_path(content_type.id, content_item.id), class: 'mdl-button mdl-js-button mdl-button--icon'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend we move this to the view, especially since we're executing html_safe here

@@ -0,0 +1,7 @@
module Buttons
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how I feel about Publishable buttons as cells, especially since all the logic for these buttons is going to be client-side (i.e. when you change published date in the interface, the data-bound button will update to reflect the change in state). At the very least, I think the namespacing for these Cells is iffy - instead of a Buttons namespace, let's go with PublishableNav::DraftButtonCell or something similar - if we used Buttons for every button cell, which the namespacing implies, we'd have a ton of objects in this namespace.

end

def content_item
@model
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want access to the model, use Cell's accessor method, model, rather than the instance var. This is generally considered safer in OOP, as it allows you to add functionality to the getter/setter at a later date that you'd otherwise have to use hooks to accomplish with an instance variable.

Copy link
Member

@toastercup toastercup Sep 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, generally, I believe we're breaking Cells by making our model be something other than what our Cell is trying to represent. To me, this is a smell - that we may be too granular in our use of cells, or that we should be passing this data in the options or context hashes, and passing nil as our model, if the use case is valid. In the past, you've had a valid use case for this - the Tree system needed the granularity of cells with nil models.

Copy link
Member

@toastercup toastercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, as was discussed in person - we'd favor a state engine of some form over building the conditional logic ourselves with our own interface that we'd have to test.

end

def publish_state
"Published"
def get_publish_state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we're favoring the get_ prefix here? I think this is a bit against the Ruby/Rails grain - getters usually are written as what they return, which in this case is just publish_state, as it was before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done because #publish_state calls the PublishState object, which existed at the time

Copy link
Contributor

@arelia arelia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acknowledging that I read through Alex's comments and looked things up

@toastercup toastercup changed the title COR-217: content publishable COR-217: Content Publishable Sep 23, 2016
@ElliottAYoung ElliottAYoung force-pushed the topic/COR-217-Content-Publishable branch from 5992bc2 to 409727f Compare September 26, 2016 18:27
@ElliottAYoung ElliottAYoung force-pushed the topic/COR-217-Content-Publishable branch from 47bff9e to 2806945 Compare September 26, 2016 19:06
@ElliottAYoung
Copy link
Contributor Author

@arelia @toastercup
Requesting Review for implementation of Transitions state machine

@ElliottAYoung
Copy link
Contributor Author

@toastercup @arelia
ContentItems will now operate off of the default state :default - which we can assume will always be the case unless overwritten by a form for a ContentType that is publishable

Copy link
Member

@toastercup toastercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After simplifying that Cells stuff, merge this sick puppy!

@@ -0,0 +1,15 @@
class ButtonsCell < Cell::ViewModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is a good candidate for an entire class.. I'd just nest it in the view, since it's not complex business logic nor does it utilize its own model

Copy link
Member

@toastercup toastercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super-neato!

@toastercup toastercup merged commit 9bc4b9c into develop Sep 26, 2016
@toastercup toastercup deleted the topic/COR-217-Content-Publishable branch September 26, 2016 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants