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
Adds asset file upload #11450
Adds asset file upload #11450
Conversation
Hey, has any designer reviewed this @javierarce? |
I can't comment it in the code, but maki icons, simple icons and pin icons disclaimers are not translated, appear in plain english. Do we agree with that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically small details, I'd like to pass the acceptance as well. Things that worry me:
- One error state that only displays a console, let's add the error view please.
- CSS discussion about keep using the old styles or break with the past and look to the future (@piensaenpixel).
@@ -21,6 +21,7 @@ module.exports = CoreView.extend({ | |||
desc: _t('components.error.default-desc') | |||
} | |||
); | |||
this._template = this.options && this.options.template || baseTemplate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.options
is always available under a Backbone View, so we don't need the first check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got an undefined error on the specs when I removed that check, I'm not sure why is not defined in this case :|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reviewed this together and found that this.options is not defined.
initialize: function (opts) { | ||
checkAndBuildOpts(opts, REQUIRED_OPTS, this); | ||
|
||
this._assets = this.options.assets; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a collection? If so, I'd call it _assetsCollection
, in order to be more specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if it is an array, _assetsArray
.
}, | ||
|
||
_initBinds: function () { | ||
this._assets.bind('add change remove', this.render, this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to use listenTo
if possible (http://stackoverflow.com/questions/16823746/backbone-js-listento-vs-on). If not remember we need to add our add_related_model
thing.
editable: this._editable, | ||
assetsCount: this._assets.length, | ||
selectedCount: selectedCount, | ||
allSelected: selectedCount === this._assets.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If assets is a collection, size
method is available.
|
||
_onClick: function (e) { | ||
this.killEvent(e); | ||
this.trigger('selected', this.model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we set an attribute called selected
within the model? With that, we could check the collection changes instead of passing a custom event to the parent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or better, I'm checking that we control that with the state
attribute. Do we need this event then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it a regular case, it would make total sense to use the model state. The reason for my decision is that changing the state of an asset in this particular case doesn't only imply the asset itself, but the state of other assets (and this changes if the shift key is pressed). In this case it made more sense to centralice the selection in a common place instead of having it separated in two different locations (view of the item and parent view)
} | ||
}, | ||
|
||
_isLoading: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen several times this function, shouldn't we move it within the proper model? Like a helper one. Same for the below one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored the upload-tab view to use the upload method from the main modal (assets-view.js)
}, this); | ||
|
||
_.each(selectedAssets, function (asset) { | ||
asset.destroy({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd not remove any asset until we have a response from the backend. Could we use here {wait: true}
within the backbone destroy method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried this at first, but I couldn't make it work using wait :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, talked with you and decided that the first approach was ok for this case (we wait until the deletion is complete and show the list again)
}, | ||
|
||
_onFetchAssetsError: function () { | ||
console.log('Error'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should render an error message, not only a console.
@@ -62,6 +62,7 @@ module.exports = CoreView.extend({ | |||
name: 'file', | |||
type: this.model.get('image') ? 'image' : 'text', | |||
label: this.model.get('image') ? this.model.get('image') : _t('form-components.editors.fill.input-color.img'), | |||
kind: this.model.get('kind') ? this.model.get('kind') : 'marker', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.model.get('kind') || 'marker'
?
@@ -95,8 +96,16 @@ module.exports = CoreView.extend({ | |||
return false; | |||
}, | |||
|
|||
_activatedFlag: function () { | |||
return this._userModel && this._userModel.featureEnabled('icon-styling'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel @matallo did something similar or I'm suffering a Dejavù??.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed! some lines below
Line 111 in 7682205
_iconStylingEnabled: function () { |
it also checks wether _imageEnabled
(this comes from editorAttrs
at editor creation) as only points geometry have image enabled. I'm not sure if this applies here, too, but in any case the this._userModel && this._userModel.featureEnabled('icon-styling')
part can be put in just one place
Not in staging, @xavijam. I'll deploy it somewhere so they can see it. |
@@ -96,20 +96,16 @@ module.exports = CoreView.extend({ | |||
return false; | |||
}, | |||
|
|||
_activatedFlag: function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it necessary anymore?
_onFetchAssetsError: function () { | ||
console.log('Error'); | ||
_onFetchAssetsError: function (model, response) { | ||
this.trigger('error', response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go to acceptance!
|
Great, thanks for discovering that @javitonino. @urbanphes could you check those? Because you checked the feature in staging (in the name of the design team 💃). |
Agree with the style of the link, sorry about that. The number of selected items didn't appear in the design, so I'd handle that in a different ticket. And for the 1px issue, I'd open a new ticket. To speed up the release of this feature, I'll take it and add the required class to fix the link style. Thanks for the thorough review! |
Styling classes added. |
@javitonino did you tried enabling/disabling the feature flag? |
Yep, there is only a small issue that if you activate it, apply a style with icons, deactivate the FF, the map keeps the icons but you cannot reset them from the style properties. But it is minor (you can reset using cartocss) and only when "downrgrading", so 👍 Everything is hidden when the FF is disabled, and everything works with it enabled ✨ |
Great, thanks! Promoting it to the next stage. |
fixes #11020
This PR enables the upload of assets using direct file upload (of single or multiple files) and also revamps the asset modal window adding tabs.
In addition of those changes, whenever a user uploads a custom asset, the input field of the Fill components shows a generic icon to indicate an image is being used as a marker.
How to do acceptance
icon-styling
flag.