I have got to the point where I can click a button on a card and show my app, but I dont know how to pass the board information to my app.
Steps:
In trello, I click on card.. then the power up button. It works, as I see this
Code:
const callback = function (t) {
return t.modal({
url: '../public/index.html',
fullscreen: true,
});
};
const t = window.TrelloPowerUp.initialize({
'card-buttons': function (t, options) {
return [
{
text: 'Hello World',
callback: callback,
},
];
},
});
In docs I see there's an args key that passes an object.
" // optional arguments to be passed to the iframe as query parameters
// access later with t.arg('text')
args: { text: 'Hello' }," - https://developer.atlassian.com/cloud/trello/power-ups/ui-functions/modal/
How do I get either my board info into args.. or use window.TrelloPowerUp.initialize or window.TrelloPowerUp.iframe within the modal?
Related
I'm trying to empty an array named Variables which is located inside alertdetails object in React as it is a fix for one of the bugs but by doing so the existing Test cases are failing in this case how do I re-write the test case so that it doesn't fail?
it('should open send template drawer when "send now" button is clicked and initiator form feature is turned on and there are variables', () => {
wrapper.setProps({
alertDetails: {
...props.alertDetails,
variables: [{ id: 1, group: 'placeholder' }]
}
});
refreshComponent('actions');
const sendButton = actions.find(CreateAlertsSendButton);
sendButton.prop('onSendNow')();
const drawer = wrapper.find(SendTemplate);
expect(drawer.prop('isOpen')).toBeTruthy();
});
it('should not open send template drawer when "send now" button is clicked and initiator form feature is turned off', () => {
const sendButton = actions.find(CreateAlertsSendButton);
sendButton.prop('onSendNow')();
const drawer = wrapper.find(SendTemplate);
expect(drawer.exists()).toBeFalsy();
});
it('should call sendAlert when send template drawer executes callback', () => {
wrapper.setProps({
alertDetails: {
...props.alertDetails,
variables: [{ id: 1, group: 'placeholder' }]
}
});
refreshComponent('actions');
const sendButton = actions.find(CreateAlertsSendButton);
sendButton.prop('onSendNow')();
wrapper
.find('SendTemplate')
.props()
.onSendNow({ placeholders: 'placeholders' });
expect(props.setVariableValues).toHaveBeenCalledWith('placeholders');
expect(props.sendAlert).toHaveBeenCalledWith(AlertSendType.SEND_ONE_STEP, { redirectUrl: '' });
});
Sorry for the extended code, the above three cases fail if I empty the Variables array
Currently, this test case checks whether we have a placeholder in alertDetails.Variables array but I need to implement it in a way that it should check from alertDetails.alertMessage so that emptying variables array doesn't affect these cases. I'd appreciate any help thanks!
Aim:
I'd like to have two models(sets of data) passed to the custom control with a predefined search field, in which later on I can execute filtering.
I'm a newbie in OpenUi5, so I might be doing something wrong and stupid here. I've started with a simplified task of passing data from the frontend to my custom control and experiencing troubles.
Background of the simplified idea:
Create a custom control with an aggregation foo , the value to it will be provided from the view.
Also create another aggregation element _searchField which will be populated with the data provided from the view.
Fire the onSuggestTerm everytime user types in a _searchField.
Custom control code:
function (Control) {
var DropDownListInput = Control.extend('xx.control.DropDownListInput', {
metadata: {
defaultAggregation: 'foo',
aggregations: {
foo: { type: 'sap.m.SuggestionItem', multiple: true, singularName: 'suggestionItem' },
_searchField: { type: 'sap.m.SearchField', multiple: false, visibility: 'hidden' }
}
}
});
DropDownListInput.prototype.init = function () {
var that = this;
this.onSuggestTerm = function (event) {
var oSource = event.getSource();
var oBinding = that.getAggregation('foo');
oBinding.filter(new sap.ui.model.Filter({
filters: new sap.ui.model.Filter('DISEASE_TERM', sap.ui.model.FilterOperator.Contains, ' Other')
}));
oBinding.attachEventOnce('dataReceived', function () {
oSource.suggest();
});
};
this.setAggregation('_searchField', new sap.m.SearchField({
id: 'UNIQUEID1',
enableSuggestions: true,
suggestionItems: that.getAggregation('foo'),
suggest: that.onSuggestTerm
}));
};
return DropDownListInput;
}, /* bExport= */true);
I'm not providing Renderer function for control here, but it exists and this is the most important excerpt from it:
oRM.write('<div');
oRM.writeControlData(oControl);
oRM.write('>');
oRM.renderControl(oControl.getAggregation('_searchField'));
oRM.write('</div>');
Passing the data to this control from the xml frontend:
<xx:DropDownListInput
id="diseaseTermUNIQUE"
foo='{path: db2>/RC_DISEASE_TERM/}'>
<foo>
<SuggestionItem text="{db2>DISEASE_TERM}"
key="{db2>DISEASE_TERM}" />
</foo>
</xx:DropDownListInput>
The code fails to run with this error Cannot route to target: [object Object] -
and I have no idea what's wrong here..
The problem is that you forgot to provide single quotes in your path:
foo="{path: 'db2>/RC_DISEASE_TERM/'}"
I have a standalone action which I call from my front end via a button click using CloudSDK, I get my value but the action does not redirect to the view. I have specified the responseType as view in my success exit but this does not seem to work.
Button code in page.js file:
clickVerifyBtn: async function(uid) {
await Cloud.userIdVerify(uid);
},
the action
module.exports = {
friendlyName: 'User id verify',
description: '',
inputs: {
uid: {
description: 'Id of the user',
type: 'number'
},
},
exits: {
success:{
responseType: 'view',
viewTemplatePath: 'pages/admin/verification-doc',
}
},
fn: async function (inputs, exits) {
// All done.
var userdoc = await Photo.findOne({ownerId: inputs.uid, isRemoved:false, photoType:0})
var imageSrc = '/images/useruploads/'+userdoc.imageFileName;
return exits.success({imageSrc: imageSrc});
}
};
What is the correct way to achieve this ? Should I submitting my value to the action via the ajax-form component bundled in Sails?
Any help is greatly appreciated.
The action2 returns the variables not to the view directly but to the view's page instance (your_view.page.js) submitted method.
I'm trying that when the user enters a command in the Web console, I get this command in the script of my addon before to be executed?
For example, when the user enters the command line "screenshot --fullpage" this command to be sent to a function of the script of my addon before being executed.
I did some research but I only found an event on the opening of the web console.
https://developer.mozilla.org/en-US/docs/Observer_Notifications#Developer_tools
Solution posted here - https://discourse.mozilla-community.org/t/firefox-addon-event-on-a-specific-command-line/6028/10?u=noitidart
Alrighty here we go, this works:
var { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
var tmp = {};
Cu.import("resource://devtools/client/shared/DeveloperToolbar.jsm", tmp);
var gcliInit = require('devtools/shared/gcli/commands/index');
var { TargetFactory } = require("devtools/client/framework/target");
var a = new tmp.DeveloperToolbar(window, document.getElementById("developer-toolbar"));
var sysTarget= TargetFactory.forTab(a._chromeWindow.gBrowser.selectedTab);
gcliInit.getSystem(sysTarget).then(
system => {
console.log('system:',system);
system.addItems([{
name: 'greet',
description: 'Show a greeting',
params: [{
name: 'name',
type: 'string',
description: 'The name to greet'
}],
returnType: 'string',
exec: function(args, context) {
return 'Hello, ' + args.name;
}
}]);
},
y => console.error('y:',y)
);
Note, the path changes in Firefox 45. So this code is for Fx45+ prior to this you would use resource://gre/modules/devtools/Loader.jsm instead of resource://devtools/shared/Loader.jsm.
TargetFactor was the key component I was missing, it's important, it's got these methods:
Object { forTab: function (), forRemoteTab: function (), forWorker: function (), isKnownTab: function () }
RxJS beginner here: I have problems with saving and tracking data changes using RxJS. Say I structure my app in small views/widgets and every view/widget has its own state and should do things on data changes. How do I do that?
More concrete example. Let's say I have a widget called Widget and Widget has a title and button. The state should contain the title and the information if the button was already clicked. From reading the docs of RxJS it seems this would be a good starting point:
var widgetState = new Rx.Subject().startWith({
wasClicked: false,
title: 'foo'
});
Now I want to be notified if some data changes:
var widgetStateChanges = widgetState.subscribe(function(data) {
console.log('data: ', data);
// what do i do with the data here?
// i would like to merge the new data into the old state
});
widgetStateChanges.onNext({ title: 'bar' });
I listen to the changes, but I don't know how to save them. I would also like to do special things, if a certain data change happens. Something like this.
widgetStateChanges.filter(function(e) {
return e.wasClicked;
}).do(function(e) {
console.log('Do something because was clicked now.');
});
However I can't filter a subscription (widgetStateChanges), only a subject (widgetState).
Use a BehaviorSubject to track observable state:
var widgetState = new Rx.BehaviorSubject({ wasClicked: false, title: 'foo' });
// change state, probably in response to UI events
// Note we always set the full state, not just the "delta"
widgetState.onNext({ wasClicked: true, title: 'foo2' });
// example listening to title input field and updating state
// assumes rxjs-jquery
$("#title").onAsObservable("change").subscribe (function (ev) {
var oldState = widgetState.value;
var newTitle = $("#title").val();
// do not mutate the oldState object, instead clone it and change the title
var newState = $.extend({}, oldState, { title: newTitle });
// send the update
widgetState.onNext(newState);
});
// listen to new state values, probably to update your HTML?
widgetState.subscribe(function (newState) { ... });
// listen only when wasClicked is true
widgetState
.filter(function (s) { return s.wasClicked; })
.subscribe(function (s) { ... });