Using Trello REST in Ionic 2 - Error TS2304 Cannot find name 'Trello' - rest

being a newbee to the ionic 2 and Trello REST interface I need help please:
As per the Trello.com site (https://developers.trello.com/get-started/start-building) I have:
Added under the html line in the index.html ie: before the body as they ask, the following and replaced the AppKey in my code:
< script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
< script src="https://api.trello.com/1/client.js?key=[AppKey]"></script>
Added code to add a card as per their example:
var myList = 'myIDLIST';
var creationSuccess = function(data) {
console.log('Card created successfully. Data returned:' + JSON.stringify(data));
};
var newCard = {
name: 'New Test Card',
desc: 'This is the description of our new card.',
// Place this card at the top of our list
idList: myList,
pos: 'top'
};
Trello.post('/cards/', newCard, creationSuccess);
However I get a typescript error:
TypeScript error: C:/workspace/...etc..../service.ts(66,9): Error TS2304: Cannot find name 'Trello'.
I thought Trello should be available to other modules since its declared in the index.html
Any help appreciated.

The Trello object might exist at runtime, but the Typescript compiler doesn't know about it, so it reports the errors. You have to provide the declaration files or simply tell the compiler that it should expect a global Trello object. For that put this line of code to the beginning of every file that uses the Trello object.
declare var Trello: any;
You can also use the node-trello package and import it directly.

Related

Keep getting 'Unexpected identifier' when running tests

I am trying to copy a tutorial for a Wordle solving bot but its just not going well. whenever I try to run a test on the code it doesn't work at certain points, I'll either get 'Uncaught SyntaxError: Unexpected identifier'. I'm doing this on UIlicious.
Here's what I've got so far:
I.goTo("https://www.powerlanguage.co.uk/wordle/")
I.click("reject")
I.see("Guess the Wordle")
I.click('/html/body', 40, 80)
let guessWord = null
for(Let r=0 ; r<6 ; ++r) {
guessWord = solver.suggestWord(gameState)
I.type(guessWord);
I.pressEnter()
I.wait(2)
}
let rowList = document.querySelector("game-app").shadowRoot. //
querySelector("game-theme-manager"). //
querySelector("#board").querySelectorAll("game-row");
you are probably referring to the article I wrote here : https://uilicious.com/blog/automate-wordle-via-uilicious/
This test script, is designed specifically to use uilicious.com, so you will need to edit and run it through the platform.
You can do so via the snippet here : https://snippet.uilicious.com/test/public/N5qZKraAaBsAgFuSN8wxCL
If you have syntax error there, do let me know with a snippet link - and I will try to help you respectively.
Also the snippet you provided so far, excludes the "solver" class which was initialised much further down.

Cloud9 & Meteor.js undefined global var

I'm trying to create the Leaderboard on Cloud9. But I get the error: PlayersList not defined... in the editor. The app is working, but then it's code in editor underlining all 'not defind PlayersList'
The code:
PlayersList = new Mongo.Collection('players');
if(Meteor.isClient){
Template.leaderboard.helpers({
'player': function(){
return PlayersList.find({}, {sort: {score: -1, name: 1}});
},
'selectedClass': function(){
var playerId = this._id;
var selectedPlayer = Session.get('selectedPlayer');
if(selectedPlayer === playerId){
return 'selected';
}
},
'showSelectedPlayer': function(){
var selectedPlayer = Session.get('selectedPlayer');
return PlayersList.findOne(selectedPlayer);
}
});
Cloud9's editor uses ESLint, and using foo = 22 makes it think that there's a missing statement like var foo; somewhere. You can either choose to ignore this, or fix it as follows:
Add /*eslint-env meteor */ to the top so it doesn't give warnings about Meteor globals, and maybe you'll also need to add /* globals Player */ added too in case the error still stays. (I haven't tested this out, please let me know how it goes so I can improve the answer)
I solved the problem with a little workaround. I added coffeescript and then I used the # symbol on the global like you should, when you define a collection with coffeescript. And that was solving it for me. It works fine. As I opened the app in an new browser window, posts were available in the console.
Example:
#Posts = new Mongo.Collection('posts')

Add trigger to form

I have been working on a simple "Time off request" form using Google Apps. The I have associated a script with the form which detects the respondents' supervisor and sends them a link to a new form for their approval.
Here is the code from the script I used to create the new form.
//create approval form as part of the Message Creation process.
var approvalForm = FormApp.create("Approve Days off Request")
approvalForm.setTitle("Approval form for " + user.Name)
// truncated ...
var approvalItem = approvalForm.addMultipleChoiceItem(); //Item on First Page
var disapproveReasonPage = approvalForm.addPageBreakItem(); //Page Break Item
var disapproveReason = approvalForm.addParagraphTextItem(); //Item on Second Page
// truncated ...
//Question 1, Page 1
approvalItem.setTitle(user.Name + " has requested " + daysOff + " day(s) off starting on " + firstDate+".")
approvalItem.setHelpText("Would you like to approve this request?")
approvalItem.setRequired(true);
approvalItem.setChoices ([
approvalItem.createChoice('Yes', FormApp.PageNavigationType.SUBMIT),
approvalItem.createChoice('No', FormApp.PageNavigationType.CONTINUE)
]);
//Question 2, Page 2
disapproveReason.setTitle("Would you like to give a reason?");
disapproveReason.setHelpText("Optional")
disapproveReasonPage.setGoToPage(FormApp.PageNavigationType.SUBMIT)
Then a link is generated and sent to the supervisor to approve the request.
I am wanting to add a trigger to the form created above (approvalForm). I would imagine that there is a way, but haven't been able to find the greatest documentation on it. The closest I've come is TriggerBuilder Class. I tried creating one associated to the target form with
var approveScript = ScriptApp.newTrigger('Approval')
.forForm(approvalForm.getId())
.onFormSubmit()
.create();
but couldn't get it to work the way I wanted it. I did have a function named Approval just to see if I could manipulate the form with it
function Approval(){
$form.setAcceptingResponses(false);
}
Any help would be appreciated. Thanks in advance.
The script was originally being added as a container bound script. Changing it to a Standalone installable script fixed this problem. Hopefully this answer will be to someone else having a similar issue.

How to overlay a cq widget so it is also available in SiteAdmin

The CQ.tagging.TagInputField provided two configuration parameter which won't work in combination:
tagsBasePath
namespaces
Using the OOTB facebook tags as example, I want to restric the dialog to only display the Favorite Teams. The Structure is this:
So I set tagBasePath to /etc/tags/facebook and namespaces to [favorite_teams]. This does what it is supposed to do and only shows the two teams in the dialog. But when you click on it, a JavaScript exceptions is thrown. The problem lies in the following method defined in /libs/cq/tagging/widgets/source/CQ.tagging.js
CQ.tagging.parseTag = function(tag, isPath) {
var tagInfo = {
namespace: null,
local: tag,
getTagID: function() {
return this.namespace + ":" + this.local;
}
};
// parse tag pattern: namespace:local
var colonPos = tag.indexOf(isPath ? '/' : ':');
if (colonPos > 0) {
// the first colon ":" delimits a namespace
// don't forget to trim the strings (in case of title paths)
tagInfo.namespace = tag.substring(0, colonPos).trim();
tagInfo.local = tag.substring(colonPos + 1).trim();
}
return tagInfo;
};
It does not respect the configurations set on the widget and returns a tagInfo where the namespace is null. I then overlayed the method in my authoring JavaScripts, but this is of course not working in the SiteAdmin as my custom JS are not included.
So, do I really have to overwrite the CQ.tagging.js below libs or can I somehow inject my overlay into the SiteAdmin so the PageProperties Dialog opened from there works as well?
UPDATE: I had a chat with Adobe support regarding this and it was pointed out that if you use tagsBasePath you need to place it somewhere else than below /etc/tags. But this won't work as well as the TagListServlet will return no tags as /etc/tags is also fixed in the TagManager as the tagsBasePath. I now overwrite the above mentioned js at its location, being well aware that I need to check it if we install a hotfix or an update. Is someone has a more elegant solution I'd be still thankful.

Joomla 3.3: Get data from column 'attribs' in the table 'content'

I'm using the Aixeena Easy CCK-plugin in my Joomla 3.3-website. It's a plugin that allows me to add custom fields in my Article Edit-page. The content I fill out there (should) show up on my website. The plugin stores his information in the #_content table in the attribs column.
On their website, Aixeena says that I have to use the following code to make the filled out text visible on my website:
$attrb = json_decode($this->item->attribs);
echo $attrb->fieldname;
This code drops the following error:
Notice: Undefined property: JDocumentHTML::$item in /Applications/MAMP/htdocs/buutpot/templates/buutpot.nl-standaardtemplate/index.php on line 123
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/buutpot/templates/buutpot.nl-standaardtemplate/index.php on line 123
Fatal error: Call to a member function get() on a non-object in /Applications/MAMP/htdocs/buutpot/templates/buutpot.nl-standaardtemplate/index.php on line 124
I think it is written for an older version of Joomla. Then I searched around and found this code:
$params = $this->item->params;
echo $params->get('fieldname');
When I use this code on my site, it gives me the following error's:
Notice: Undefined property: JDocumentHTML::$item in /Applications/MAMP/htdocs/buutpot/templates/buutpot.nl-standaardtemplate/index.php on line 123
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/buutpot/templates/buutpot.nl-standaardtemplate/index.php on line 123
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/buutpot/templates/buutpot.nl-standaardtemplate/index.php on line 124
That's without a fatal error. I'm not sure why it is without.
Could anybody help me out getting the right code to get my variable out of the table? Thanks in advance!
EDIT 1: Link to the plugin: http://www.aixeena.org/aixeena-lab/aixeena-easy-cck
EDIT 2: Edited my question in reply on the comment of Elin.
So like the notices say, the problem is that $this->item does not exist. You need to figure out what the actual name of the object is and use that rather than $this->item. You will probably do that by looking in the layout of whereever it is that you are trying to display. Can you please check your template to see if it has a layout override for the article view (assuming that is the view you are trying to access the form from)?
I used this code to do a query on the database:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('attribs');
$query->from($db->quoteName('#__content'));
$query->where($db->quoteName('id')." = ".JRequest::getInt('id'));
$db->setQuery($query);
$attribs = $db->loadResult();
$attribs = json_decode($attribs, 'true');
$firstattr = $attribs['firstattr'];
$secondattr = $attribs['secondattr'];
$thirdattr = $attribs['thirdattr'];
$fourthattr = $attribs['fourthattr'];
But I'm sure this can be done simpler.
$attribs = new JRegistry($article->attribs);
echo $fieldname = $attribs['fieldname'];
For example, I use this code in on ContentPrepare like this
function onContentPrepare($context, &$article, &$params, $page) {
$attribs = new JRegistry($article->attribs);
//url is my custom field for the content
$url = $attribs['url'];
......