Skip to content

Conversation

@staturecrane
Copy link
Contributor

@staturecrane staturecrane commented Jul 18, 2017

This pull request fulfills the following tasks:

  • FS-1339 Add Javascript include tag
  • FS-1337 Change naming coventions from Filepicker to Filestack
  • FS-1345 Remove save button

Initialization

The v3 picker is initialized as a variable on the client side. To deal with this, there are now two tags that must be added:

<%= filestack_js_include_tag %>
<%= filestack_js_init_tag %>

The first of which loads the v3 Picker onto the page, while the second tag initializes it. You can define a custom client name in the config options as such:

config.filestack_rails.api_key = 'your_api_key'
config.filestack_rails.client_name = 'custom_client_name'

Which can then be referenced via:

// in app/assets/javascripts
console.log(custom_client_name)

Otherwise the name defaults to "filestack_client".

Another element has also been added, the filestack_picker_element (name open to discussion). It functions as a button that can be added to any page, which accepts a Javascript callback to handle return data from the API. Example usage would be such:

// in app/assets/javascripts
function handlePickerData(data){
    console.log(data.filesUploaded[0].url)
}
<%= filestack_picker_element "button_content", "handlePickerData" %>

Everything else that has been added has been to set up the next tasks, and as there is significant differences in the way that v2 and v3 Pickers behave, a lot of the code has been excised or rewritten. After looking through the issues, I have been careful to ensure we keep proper namespacing and that we are not modifying/affecting global rails options or names as much as possible.

@staturecrane staturecrane requested a review from kyuss July 18, 2017 20:03
@coveralls
Copy link

Coverage Status

Coverage decreased (-10.0%) to 90.0% when pulling cda70a7 on feature/FS-1339-add-javascript-include-tag into cc149dd on develop.

@staturecrane staturecrane merged commit 92be0c0 into develop Jul 19, 2017
@staturecrane staturecrane deleted the feature/FS-1339-add-javascript-include-tag branch July 19, 2017 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants