Fail on that syntax .liquid (learning stage) - syntax-error

on my way to learn .liquid, i can't found issue on that syntax:
{{ 'visa.svg' | asset_img_url | image_url: width: 36, height: 36 | image_tag: alt: 'Visa', srcset: nil, class: 'filter-green', loading: 'lazy' }}
Fail: Liquid error (sections/footer.liquid line 264): invalid url input
Where is the fail? :(

It's because 'visa.svg' is not an image type object (nor 'visa.png' is).
asset_img_url returns URL and image_url expects image object. So there is a conflict "wrong input".
From docs:
image_url Returns the URL of an image. You can use image_url on the
following objects:
product, variant, line, item, collection, article, image
The Image Object
An image object returns information about an image. Image objects are usually attributes of other objects, such as product, variant, collection, and article.

Related

vue-cookies get value return Object instead of actual value

I am using vue-cookies npm package in my vue project. I have no problem install the package, initialize it in the project and setting the cookie. However, when I tried to retrieve the value stored in the cookie by key, instead of showing me the value I stored, it showed me [object Object], and I am not sure what went wrong:
Here is my code:
this.cart.push({
productID: this.product._id,
product: {
productName: this.product.productName,
thumbnail: this.product.productMedia[0].imagePath,
option: 'Digital Download'
},
unitPrice: this.product.price.listingPrice,
quantity: 1
})
console.log(this.cart)
this.$cookies.set('cart', this.cart, 60 * 60 * 24)
console.log(this.$cookies.isKey('cart'))
console.log(this.$cookies.get('cart'))
I made sure this.cart is not empty, $this.$cookies.isKey('cart) returned true, however, $cookies.get() method returned [object Object]instead of the cart value I stored. Any help is appreciated!
While setting the JSON object in the cookie. You can set the key value as JSON string instead of JSON object.
this.$cookies.set('cart', JSON.stringify(this.cart), 60 * 60 * 24)
While getting then you can access by parsing the JSON string into an object.
JSON.parse(this.$cookies.get('cart'))
If you want to see the value in the console try doing
console.log(JSON.stringify(this.$cookies.get('cart')))
The object in question may be nested which is why it won't print.

What does getHandlerId() do and how to use it?

Some of the react-dnd examples use a getHandlerId() method.
For example in the simple example of a sortable list, the Card.tsx function:
Collects a handlerId from the monitor object within the useDrop method
collect(monitor) {
return {
handlerId: monitor.getHandlerId(),
}
},
Returns that as an element of the "collected props"
const [{ handlerId }, drop] = useDrop<
Uses it to initialize an HTML attribute named data-handler-id
<div ref={ref} style={{ ...style, opacity }} data-handler-id={handlerId}>
What is this Id and why is it used?
What uses the data-handler-id attribute?
I'd expect to see getHandlerId() described in the API documentation as a method of the DropTargetMonitor (but it isn't).
I didn't dive deep into it but for me this information was enough to continue using it:
If you remove this data-handler-id, everything continue working but with some issues (item sometimes flickers, it doesn't go to another place as smoothly as it does with data-handler-id)
Here is an open issue https://github.com/react-dnd/react-dnd/issues/2621 about low performance, and this comment suggests to use handler id: https://github.com/react-dnd/react-dnd/issues/2621#issuecomment-847316022
As you can see in code https://github.com/react-dnd/react-dnd/search?q=handlerId&type=code, handler id is using for proper definition of drop item so it seems better to use it even if you don't have a lot of elements.

GoodData charts components throwing error of TypeError: item.predicate is not a function on setting color from configuration

On setting colors from configuration and using Gooddata UI Charts component it is throwing following error
TypeError: item.predicate is not a function
My config is as follows, On reseting default color it is working fine but as change color i get the colorMapping object in the api and after applying this config throwing the error.
How can i resolve it, Please help me out.
config={{
colorMapping: [{
color: { type: "guid", value: "17" },
id:"0d447449c2844b228923c37de7b6aaf9"
}]
}}
usage of ColorMapping is described in documentation
https://sdk.gooddata.com/gooddata-ui/docs/chart_config.html#Color-mapping
You need to define predicate function which when returning true, will apply corresponding color (https://sdk.gooddata.com/gooddata-ui/docs/ht_create_predicates.html).
In your case localId predicate seems to be right for you
https://github.com/gooddata/gooddata-ui-sdk/blob/master/libs/sdk-ui/src/base/headerMatching/HeaderPredicateFactory.ts#L264
In case you are using older version of Gooddata UI.SDK than v8, you need to implement predicate by your own. Something like this (or equivalent for measures).
predicate: headerItem =>
headerItem.attributeHeaderItem &&
headerItem.attributeHeaderItem.localIdentifier === "0d447449c2844b228923c37de7b6aaf9", // find attribute item by localIdentifier
You can switch the official documentation to whathever version of Gooddata UI.SDK lib you are using and read the same article about ColorMapping
https://sdk.gooddata.com/gooddata-ui/docs/7.9.0/chart_config.html#color-mapping

Vuetify, v-data-table headers value purpose

What is the purpose of the value property in headers array of objects for v-data-table?
In the documentation it says
An array of objects that each describe a header column. See the example below for a definition of all properties.
{
text: string",
value: string",
align: 'left' | 'center' | 'right'",
sortable: boolean",
class: string[] | string",
width: string"
}
But it never actually explains the purpose of it.
Does the header object just need a unique key or can I can someone use that value in the html?
When you define that column as sortable: true, it is the value, and not the text, that will be set on the pagination object.
For instance, my column is called Created at (text), and it's value is created_at. This allows me to watch the pagination object, and send the order by data directly without an extra mapping step, as my API expects the value of orderBy to be either created_at or nothing.

yadcf "select_type_options" not effective for Chosen

I am using yadcf to create a filter with "select_type":"chosen"in a separate large container. As the chosen-Dropdown was rendered too small, I added "select_type_options":"width:200px;" but that has not had any effect. Does that info need to be provided in a different format - or have I hit a bug?
Its not a bug, select_type_options property type is an object, so you should feed it an object value with key/value
Fix your code from
"select_type_options":"width:200px;"
into
select_type_options: { width: '200px;' }
See from docs:
* select_type_options
Required: false
Type: Object
Default value: {}
Description: This parameter will be passed "as is" to the Chosen/Select2 plugin constructor
You can also find this in the showcase code snippet