I have a JSON file that I am calling with Axios to fetch data, in the data is a value. When this value is present, I want to change the background colour. Sounds simple enough but I am struggling with the logic of this.
Here is my code:
https://gcpzn.csb.app/
Here is some of my thinking on how to solve this:
In the test.json data above we get the data of type: "dev"
there will be dev, stage, live
from this JSON data, I need to be able to change the background colour based on these values
I was thinking of using a switch statement but this is where I am stuck at.
If the item.type is dev then I want the background to change to yellow
If the item.type is stage then I want the background to change to red
If the item.type is live then I want the background to change to green
How would you go about solving this issue as I am stuck and need a little help, please?
Thanks,
Dave.
You forget that calling an API is an asynchronous process.
Here is your modified code.
Related
I'm trying to make a dialog which shows a dynamic carousel with botkit.
I want the items in this carousel to change according to data on a JSON, I already have a function which creates and updates an "attachmentJSON" variable in the correct format using the data from the original JSON, so it should look something like this:
dialog.ask({ "attachment": attachmentJSON }
The function that updates attachmentJSON is called by several different 'bot.hears' on runtime.
Is there a way to do what I'm trying to do?
I really doubt it's the best solution, but what I ended up doing is creating a function which overwrites the dialog using the updated JSON, and call this "updateConversation" function everytime I need it.
It works at the very least.
I would like to style a couple of elements using a filter to decipher if it should be yellow or red.
I understand filters should not carry logic operations in them as such so am guessing a service is the first port of call before i create any filter for it.
I am leveraging data from a backend (still a bit unsure of the Backend model here, but know I can leverage certain objects to obtain the data needed for working on) I mostly need to know if i`m on the right path by using a service to control the logical outcome and then a filter to provide 'filtration' of that outcome.
BTW: sorry, im waiting for my project to checkout from SVN at mo so cannot provide a skeleton attempt.
Will do in a bit though .....
Any advice before hand will be much appreciated
:) Gruffy - thanks for reading
You can directly set the class attribute if you want, so your filter can simply return the CSS class to apply:
<p class="{{'foo'|myFilter}}">Foo</p>
Here's a fiddle showing what I mean.
I'm trying to convert the Adjuster example mentioned here: http://agiletoolkit.org/learn/understand/view/interactive
into a View that is able to show me the next/previous picture of a list of given images.
I guess the number in the example could be an index into an array of pictures.
I'm just not sure how to provide the list of pictures, when all the code is put in init() for the View, so no way to give it the picturelist before that...
Should I use memorize/recall for this list also to prevent it getting lost upon reload ?
is there another example that might help me?
I think you what you are doing can be much easier done with a classic JavaScript Lightbox script. You would supply it list of images and it would show one full-screen.
If not, you can use this:
https://gist.github.com/romaninsh/7217119
This will give you slides similar to the ones on http://agiletech.ie/
Be advised that this code is a little old.
In sencha (http://www.sencha.com/products/extjs/) I was wondering is it possible if i can have a bar chart, or a pie chart and have the data exported? I would like to go back from a chart to a printed data in my hand.
** if i have a bar chart that has data already plotted on it and now i would like to get the x-axis in one column and have the y-axis in another column but i would like to have that exported so i can printed it out. I do not want the chart to be printed.
My question is: Is there a way to do that? and if so what is the code that is needed or used?
CAN I ALSO DO IT IN ZINGCHARTS.COM
what about zingcharts?? i have done my research and found that they have this code called zingchart.exec("yourChartId", "exportdata"); i just dont know how exactly to put it in my zingcharts.rendering function can i get help on that?
I see that this is an older question, but hopefully this will help you or someone else with a similar issue.
The ZingChart exportdata method doesn't actually go in the zingchart.render method, it's its own API method.
zingchart.exec('myChartDiv', 'exportdata', {
url : 'www.zingchart.com/resources/exportdataurl.php'
});
'myChartDiv' refers to the id given to the div in your page where your chart renders. You can either set the 'url' option in the export data method options, like I did above or you can set the 'exportdataurl'. The data is sent as POST data via HTTP.
Just to get the data? Sure.
Charts are populated by a store object, which is a container with all the data.
To get the data out of the store is pretty forward.
Eg:
store.each(function(store,record,e){console.log(record);});
You can probably use Export store to Excel user extension published on Sencha forum.
I am trying to figure out how to make a hyperlink in a Livecycle Form which points to a URL which will change on different days that the form is rendered. For example on one day I might want the hyperlink to point to:
mywebsite/mypage?option=XXX
and on another day I want it to point to:
mywebsite/mypage?option=YYY
The XXX and YYY can be passed into the form's data pretty easily as XML, but I just don't know how to make it so that the hyperlink is changed to correspond to this.
Any suggestions?
This can be accomplished with JavaScript in LiveCycle Designer. The following script, placed on the Form's docReady event will let you dynamically change the URL of a text object.
form1::docReady - (JavaScript, client)
// If this code is running on the server, you don't want it to run any code
// that might force a relayout, or you could get stuck in an infinite loop
if (xfa.host.name != "XFAPresentationAgent") {
// You would load the URL that you want into this variable, based on
// whatever XML data is being passed into your form
var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx
// URLs are encoded in XHTML. In order to change the URL, you need
// to create the right XHTML string and push it into the Text object's
// <value> node. This is a super simple XHTML shell for this purpose.
// You could add all sorts of markup to make your hyperlink look pretty
var sRichText = "<body><p>Foo</p></body>";
// Assuming you have a text object called "Text1" on the form, this
// call will push the rich text into the node. Note that this call
// will force a re-layout of the form
this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true);
}
There are a couple of caveats: URLs in Acrobat are only supported in Acrobat 9.0 and later. So if someone using an older version of Acrobat opens your form, the URLs won't work.
Also, as you can see from the "if (xfa.host.name !=...)" line, this code won't run properly if the form is being generated on the server, because forcing a re-layout of a form during docReady can cause problems on certain older versions of the LiveCycle server. If you do need to run this script on the server, you should probably pick a different event then form::docReady.
I a number of complaints from users in WorkSpace that clicking links opened them in the same tab so they lost their WorkSpace form, and there's no option to change that in Designer 11. I think the solution I came up with for that would work for you too.
I made buttons with no border and no background, and in their click event have this line (in Javascript, run at client)
app.launchURL("http:/stackoverflow.com/", true);
It would be easy to add some logic to choose the right URL based on the day and it doesn't cause any form re-rendering.
In some spots where the hyperlink is in line with other text, I leave the text of the link blue and underlined but with no hyperlink, and just place the button (no background, no border, no caption) over it. Does require positioned and not flowed subforms for that to work, so depending on your layout it could get a little clunky.
Wow, just realized I am super late to the party. Well, for anyone using ES4 facing a similar problem . . .
Ended up using a 3rd party component to manipulate the PDF's hyperlinks...wish there was a better solution as this one costs about $1000.