Flow type for an array of HTML elements? - flowtype

I'm converting some working JavaScript code to Flow. I have a variable IMAGES which is created but not immediately assigned any value. Later on it becomes an array of HTML elements.
Why is this code wrong?
let IMAGES Array<HTMLElement>;
// Later on within an init function:
IMAGES = Array.from(document.querySelectorAll(`.${someImagesClass}`));
The Flow error I get is:
Parsing error: Unexpected token, expected ";"

All I was missing was the :
let IMAGES: Array<HTMLElement>;

There is no generic-syntax and no need to "publish" a variable in JavaScript! Just merge both:
// Later on within an init function:
let IMAGES = Array.from(document.querySelectorAll(`.${someImagesClass}`));

Related

Watir: Problems trying to get the value of a field that's contained within an iframe

I'm trying to verify the text within a field that's held in an iframe using the shown in the image below.
When I run it I get this syntax error:
/opt/homebrew/lib/ruby/gems/3.0.0/gems/watir-6.19.1/lib/watir/elements/element.rb:857:in method_missing': undefined method value' for #<Watir::HTMLElement: located: false; {:width=>"100%", :tag_name=>"iframe"} --> {:id=>"P5533_COMPANY"}> (NoMethodError)
from temporary_exp.rb:83:in `'
If I use the code for performing a 'click' e.g. browser.iframe(:width =>"100%").element(id: "P5533_COMPANY").click then it works fine but for some reason it doesn't like 'value'. Any ideas?
This is the code I'm running
#value is not a method in Watir::HTMLElement object, which is what you get an instance of when you use #element method. Is the HTML element you are working with a Checkbox? (then use #checkbox instead of #element)

Uncaught (in promise) FirebaseError: Invalid document reference. Document references must have an even number of segments

Well, My issue is different.. I created a modal form like this:
Modal Form
There is no issue at all and my data can be edited easily:
Updates with no errors
Now, I started to replace the text area with Vue2-editor plugin and the resulting design is like the following:
Vue-text-editor
I tried to modify the texts and save:
Error
Here is my updating mechanism:
updateProduct() {
// Update function has issues so I have to apply this work-around
this.$firestore.products.doc(this.product['.key']).set(this.product).then(() => {
this.$firestore.products.doc(this.activeItem).delete()}).then(()=>{
this.$refs.edit.hide()
toast.fire({
type: 'success',
title: 'Updated successfully'
});
});
},
Well, the firebase update function does not work at all. I have researched this, but in vain - this is the only working workaround for it.
Now I need to figure out what's wrong with that text editor.
Your problem is here:
this.$firestore.products.doc(this.product['.key'])
I don't know what the contents of this.product['.key'] is, but it's almost certainly not going to give you the name of a collection and the name of a document together. The only way you can reference a document is through a collection. Documents don't exist outside of collection. That's why the number of path segments in the string you pass to doc() must be even. It should be of the form "collection/document".
You will have to identify the collection you're writing to, and reference the path of the document using it.

Are there Tags that could solve this?

New to coding, trying to see what/if Tags would make this code work
So I'm a beginner with basic understanding and more of a Graphics/ Designer than code based. I found a codepen by WEDOO that has exactly what I need and want to try to just swap my "animationData" to see if I can get it to work and then modify it as needed for my test (will be assign the button code to various objects for the SVG). I Can't seem to find the right "Tags" or determine if its referencing an external script...I'd image it just needs the right information to function...is that correct?
Thanks in advance!
var animation = bodymovin.loadAnimation({
container: targetAnim,
path: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/914929/data-testo4.json...
My output from BodyMovin in a JSON file:
var animationData =
{"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
Does it make sense to think that I need replace the var animation with info that should be the targetAnim with the code in the JSON file? So far put the var animationData breaks things and does nothing (visually).
The bodymovin.loadAnimation can be passed either a URL to a Bodymovin JSON via the path option OR you can pass the animation JSON inline by setting the animationData option instead.
In you case it would end up looking something like:
var animation = bodymovin.loadAnimation({
container: targetAnim,
animationData = {"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
...
})

Retrieve explicit values from document library

I'm trying to pull some fields from my Document Library. Right now, I can retrieve these 2 fields to return the correct values, in my success function.
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
alert(oListItem.get_item('Title'));
alert(oListItem.get_item('UserField1'));
}
But when I try to call a computed field, such as 'NameOrTitle' oListItem.get_item('NameOrTitle')); I get IE telling me the property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
This value has content inside it right now. And I need it, as it's displaying the file name. How can I get this field? I have looked elsewhere and I have read stuff about doing:
context.load(allItems, 'Include(NameOrTitle)');
Then in my succeess function, I do oListItem.get_nameOrTitle(). Is this correct?
Well I do that and now I'm getting
Object doesn't support property or method 'get_nameOrTitle'
Please help. Thanks.
oListItem.get_item('FileRef');
Will get me the url

filter functions problem

I'm working on a search component for an app I'm working on and I needed to add some filters to it. I've found an example and got the first filter working fine.
Now I'm trying to add a second filter I'm running into problems... In the example I found they use filterFunctions, but I only get an option for filterFunction, why is that?
Here's the example code
productsCollection.filterFunctions =
[
filterByPrice, filterByType,
filterByCondition, filterByVendor
]
And this is what I'm trying
acData.filterFunction = [filterByStatus, filterByDate]
but with this code I get the following error message - 1067: Implicit coercion of a value of type Array to an unrelated type Function.
Why am I getting this error and how would I go about add multiple filters to my Array Collection?
Thanks!
filterFunction must be set to a single function, not an Array or any other datatype. To combine multiple functions create one that combines them, like this:
acData.filterFunction = function(item:Object)
{
return
filterByPrice(item) &&
filterByType(item) &&
filterByCondition(item) &&
filterByVendor(item);
};
If you saw a sample that used filterFunctions plural that accepted an array, post a link. That's not anywhere in the standard Flex framework or in the new 4.0 beta afaik.
It looks like you are going to have to extend an arraycollection to make it work. this link should spell it out for you: http://blog.rotundu.eu/flex/arraycollection-with-multiple-filter-functions/

Resources