paper-dropdown-menu this._setValue(value); - polymer-1.0

i'm trying to understand the Polymer paper-dropdown-menu element but on line 355 there is a line
this._setValue(value);
I've searched the code and the code of the behaviours but can't figure out where the method _setValue is coming from?
can someone help me understand?
thanks

The _setX(val) method is added by Polymer element constructor dynamically for read-only properties.
Polymer({
is: 'paper-dropdown-menu',
properties: {
value: {
readOnly: true
}
},
someFunction: function() {
this._setValue('x');
// this will fail
this.value = 'x';
}
});
See the documentation for reference.

Related

Polymer 1.0 observers - not working on array

I set an observer on to catch all polymer recognized events on an property that is an array, but I catch get it to catch the change. In my example below my observer function "bigup" only gets called on when the property, "bigs" is first initialzed.
<dom-module id="parent-page">
<template>
<paper-button on-click="updateAll">Update</paper-button>
</template>
<script>
var temp=[];
temp.push({'conversation':[{'message':'hello'}]});
Polymer({
is: 'parent-page',
properties: {
bigs: {
type: Array,
value: temp
}
},
observers: [
'bigup(bigs.*)'
],
updateAll: function(){
this.bigs.push({'conversation':[{'message':'hola'}]});
console.dir(this.bigs);
},
bigup: function(){
console.log('big Up');
}
});
</script>
I also tried to use bigs.push in the observer but had no success. One part I don't understand is that if I add the following line to my "updateAll" function, the observer catches the change and fires "bigup".
this.bigs=[];
For me this article was helpful as well, it covers both the way to register the observer as well as the splices methods as suggested by Justin XL.
Registering the observer:
properties: {
users: {
type: Array,
value: function() {
return [];
}
}
},
observers: [
'usersAddedOrRemoved(users.splices)'
],
Calling splices methods the Polymer 1.0 way:
this.push('users', 'TestUser');
https://www.polymer-project.org/1.0/docs/devguide/properties.html#array-observation
FYI - this will NOT work in all cases (my initial idea)
When you register the observer in the property declaration like this:
properties: {
users: {
type: Array,
value: function() {
return [];
},
observer: 'usersAddedOrRemoved'
}
},
In this case the usersAddedOrRemoved method is only called when you assign a new array to the users object. It will not however fire when you mutate the array by pushing, popping, splicing etc.
You need to use the push method from Polymer instead of doing this.bigs.push.
So replace that line of code with
this.push('bigs', {'conversation':[{'message':'hola'}]});
For more info have a look at this link.

Lazy repeat calculateItemHeight index is always undefined

I'm using ons-lazy-repeat and I want to have variable item heights depending on the item.
For that I'm using, as described in the documentation, a delegate object with a calculateItemHeight function.
The problem is all item heights are being set to 20 because initially the index variable is always undefined. Afterwards everything seems to work correctly but everything is already rendered on the ui.
Anyone else have the same problem? I don't see what I'm doing wrong here.
This is my delegate object:
$scope.TransactionDelegate = {
configureItemScope: function(index, itemScope) {
itemScope.item = TransactionService.allTransactions[index];
},
calculateItemHeight: function(index) {
if (!index)
return 20;
return 60;
},
countItems: function() {
return TransactionService.allTransactions.length;
},
destroyItemScope: function(index, scope) {
;
}
};
Thanks
This is a know bug that is now fixed and will be released in the next version.

Need Extjs Simple Login code

need extjs code for login. if username="admin" & password="admin" open new panel else show error alert. Please Help me. thanks in advance
buttons: [{
text: 'Login',
handler:function(){
simple.getForm().reset();
}
//handler:loginclk
/** var usnme=Ext.getCmp('usr').getValue();
var pswd=Ext.getCmp('ped').getValue():
if(usnme=='admin' && pswd=='admin'){
Ext.MessageBox.show({Fine});
}
else { Ext.MessageBox.show({wrong });
}
handler : function() {
if(uname=="admin" && pwd=="admin"){
window.redirect();
}
I Tried these two codes but it doesn.t works
Ext.MessageBox.show() takes a config object, you are passing in undefined variables Fine and wrong.
Instead:
Ext.MessageBox.show({text: 'Fine'});
You must be seeing errors in your console too?
This handler code should work for you:
handler : function() {
var usnme=Ext.getCmp('usr').getValue();
var pwd=Ext.getCmp('ped').getValue():
if(uname=="admin" && pwd=="admin"){
window.redirect();
} else {
Ext.MessageBox.show({text:'Wrong'});
}
}
Provided the id's you have assigned to your inputs are correct 'usr' and 'ped'

Changing test set of an existing test case in Rally using Ext Js

I want to create a report where where we have capability to reparent our test cases from one test set to other.
in simple language, I need to remove the existing link with the test set and assign a new test set for my existing test case/cases.
I was referring to one existing report at https://github.com/RallyTechServices/test-picker/blob/master/deploy/App.html
listeners: {
scope: this,
artifactChosen: function(items){
Ext.create('Rally.data.WsapiDataStore',{
model:'TestSet',
pageSize: 1,
autoLoad: true,
filters: [{property:'ObjectID',value:record.get('ObjectID')}],
listeners: {
load: function(store,records){
console.dir(records.length);
var ts = records[0];
me._log(["Selected items:",items]);
var tc_store = ts.getCollection('TestCases');
me._log(["Got store:",tc_store]);
tc_store.add(items);
me._log("Added items.");
tc_store.sync({
// callback: function(){
// me._log("inside callback");
// me._getTestSets(me.iteration_selector.getValue());
// }
success: function(batch,options) {
me._getTestSets(me.iteration_selector.getValue());
},
failure: function(batch,options) {
me._getTestSets(me.iteration_selector.getValue());
}
});
}
}
});
}
}
Here If I try to use remove it gives me an error, I am not sure what is causing the issue.
Or How can I approach the issue. I need to change the test set of any user selected test case in my report. Can please some help me on the same.
The error is "Uncaught TypeError: Cannot read property 'getRef' of null". When it can add to the same object why cant it delete. I understand that it has only one value. but I tried removing the filters as well from code snippet mentioned below, but still it gives only current selected test case object id.
Thanks in Advance

Sencha scope issue

I've completely rewritten my question to hopefully better reflect what I am trying to do here. Thank you guys so much for your help so far.
I have a file called en.js, which holds this code:
Ext.apply(Ext.locale || {}, {
variable: 'great success!'
});
Here's my index.js setup code:
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady: function() {
Ext.locale = {};
var headID = document.getElementsByTagName("head")[0],
newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'en.js';
headID.appendChild(newScript);
loginPanel = new login.Panel();
}
});
login.Panel is an extension of the Sencha panel class using Ext.extend.
The 'en.js' script is added to the header correctly. I don't have it in the index.html file because once this problem is solved there will be several files that could be loaded, depending on the output of a function. That's why I need to add the script to the header in the onReady function, and not in the index.html file itself.
Once the script has been added it loads "variable: 'great success'" into Ext.locale,
Yet my problem currently lies within login.Panel(), which is an extension of the Sencha panel class using Ext.extend.
Currently, there is a button in the panel.
When I put this in the button's handler:
console.log(Ext.locale.variable)
it returns the string "great success",
yet when I try to set the button's text like this:
text:Ext.locale.variable,
I get the error
Uncaught TypeError: Cannot read property 'variable' of undefined
I'm guessing I have a scope issue here, since console.log() and alert() can both access Ext.locale, but trying to use it to construct the form gives me the undefined error.
Any help would be greatly appreciated.
Thank you!
it sounds like you are defining Ext.locale from your script early on... then later in onReady you are overwriting it as Ext.locale = {}
onReady will run after all your other scripts have been loaded.
Why not move your initialisation code for locale into onReady insted of your = {} line
This will add three properties and their values to the receiving object.
Ext.apply(receivingObject, {
property1: 'value1',
property2: 'value2',
property3: 'value3'
});
Here also is the Sencha documentation on the Ext.apply method:
http://dev.sencha.com/deploy/touch/docs/source/Ext.html#method-Ext-apply
As for accessing the isReady property, you could do something like if(someExtObj.isReady), but you may be more interested in using the onReady method...
Ext.setup({
onReady: function() {
// your setup code
}
});

Resources