Model in sencha (array/object) - sencha-touch

{ name: 'status', type: 'object' },
This is the fields in a model.
Can i define status.status1="value1", status.status2="value2" and so on..
if yes...then how?
If this is not possible, then can i use array in type??

If I understand the question correctly, what you're looking for is a store. Here's an example:
Ext.define('AppName.store.Statuses', {
extend: 'Ext.data.Store',
config: {
model: 'AppName.model.ModelName',
data: [
{ name: 'name1', status: 'status1' },
{ name: 'name2', status: 'status2' },
{ name: 'name3', status: 'status3' },
]
}
});
The above code would go in a store directory within your app folder, in a file called StoreName.js. Here, the data is hard coded in, but a store is generally used to load data through an AJAX call. See the docs for more information about that. The store is generally named as the plural of the model name. For example, if your model was defined as Status, then the store would be named Statuses.
I hope that helps!

Just set the field type to 'auto', see this Sencha forum post

Related

How can I use Vuelidate to validate an empty collection?

I am trying to use the same form for create and update.
Everything is working great when I am updating an existing location. It's when I am creating a new location that my validation is causing an error.
I can understand why it's unhappy, I don't have anything to validate. I don't understand what I am doing wrong though.
Looking at the docs, I believe I'm setting up the validation rule properly:
location: {
messaging: {
$each: {
email: {
fromName: { required },
fromAddress: { required },
},
},
},
...
}
I am passing location in as props with a default of:
...
messaging: [{
email: {
fromName: '',
fromAddress: '',
},
}],
When saving the data, it has the correct shape I'm looking for as well:
[{"email":{"fromName":"No Reply <noreply#example.com>","fromAddress":"noreply#example.com"}}]
My input looks like this:
<input id="fromName"
v-model.trim="$v.location.messaging.$each[0].email.fromName.$model"
type="text"
...
The error I am getting is
Cannot read properties of undefined (reading 'email')"
I understand that email is undefined, nothing exists (yet). How can I set up the validation collection so it knows what email is?

How do I use an asynchronous query to read in a list of to-dos?

I'm making a simple to-do list application but I need to use an asynch query to fill the tasks on the webpage with what is in the json (I am given a link where the list of todos are). How do I do this? I've been searching everywhere and am stuck. Right now, it is only showing tasks I add, or a task I have manually inputted under data.
This is what I have in the first part for data
el: '#app',
data: {
items: [{
text: "test1",
completed: false,
}],
text: '',
show: 'all',
},
I would check out the library axios for this task. Check out this example: https://v2.vuejs.org/v2/cookbook/using-axios-to-consume-apis.html

Agile Central Basic App Settings

I'm implementing a simple app based on the UserIterationCapacity using a Rally.app.TimeboxScopedApp.
Now I want to specify a couple of settings as App settings and found the developer tutorial for this: https://help.rallydev.com/apps/2.1/doc/#!/guide/settings
But I just cant get it working. Whenever I try to fetch a setting my code stops without any warnings.
I've implemented the following:
config: {
defaultSettings: {
hoursPerSp: 6,
decimalsOnHoursPerSp: 1
}
},
getSettingsFields: function() {
return [
{
name: 'hoursPerSp',
xtype: 'rallynumberfield'
},
{
name: 'decimalsOnHoursPerSp',
xtype: 'rallynumberfield'
}
];
},
Now I'm trying to use
this.getSettings('hoursPerSp');
but unfortunately it is not working.
Thank you in advance
Problem solved.
I needed to keep track of my scope, i.e., I needed to pass in the this variable to my renders.

Only change one viewport in Aurelia router

Good morning, I have my route setup as shown below within Aurelia CLI.
config.map([
{
route: [''],
viewPorts: {
'side': { moduleId: 'side' },
'main': { moduleId: 'main' }
},
title: 'Test',
nav: false,
name: 'Temp'
]);
What I would like to do is based on what I select on my side view, I just want to change the moduleId for main and load that view.
I don't think there's a way to dynamically change the moduleId of a view-port. I see 2 options to solve your proble:
1 - Create another route, changing the moduleId of one of the viewports
2 - Use the layout mechanism and change its content in run time. I recommend you to read http://aurelia.io/hub.html#/doc/article/aurelia/router/latest/router-configuration/10.
I know this is not the answer you were expecting but I hope it helps.

Get values from localStorage to use in Sencha Touch AJAX Proxy

In my Sencha Touch application I store some values in localStorage and they get stored just fine. Later I need to use those values for a request to a store and I need to pass those values as request headers. The code looks like the following:
Ext.define('AppName.store.storeName', {
extend: 'Ext.data.Store',
requires: [
'AppName.model.modelName'
],
config: {
model: 'AppName.model.modelName',
storeId: 'storeName',
proxy: {
type: 'ajax',
url: 'http://dynamic',
headers: {
auth_token: localStorage.getItem('activeUserToken'),
user_email: localStorage.getItem('userEMail')
},
reader: {
type: 'json'
}
}
}
});
However, both auth_token and user_email values are being returned as "undefined" when in Chrome developer tools I clearly see those values. Besides of that I access those values in many other places in my Sencha Touch application but can't do that in the store itself.
Could anybody please tell me what I'm doing wrong?
Thanks
I've solved this problem in the following way. Instead of passing the headers in the store I'm passing the headers during the request, before loading the store. Here's the code for that:
Ext.getStore('storeName').getProxy().setUrl(someURL);
Ext.getStore('storeName').getProxy().setHeaders(
{
"auth_token" : activeUserToken,
"user_email" : userEmail
}
);
Ext.getStore('storeName').load();