Adding a view that displays user data using store Sencha touch2 - extjs

My store JSON looks like this:
"content" : {
"RecId" : "123",
"CustNo" : "123",
"Attn" : "",
"AcctManagFirst": "Sample ",
"AcctManagLast": "Sample2",
"Name": "Works",
"Terms": "1234",
"Freight":0,
"Taxable":1,
"TaxTable": "EXEMPT",
"TaxTableRate": "0.000000",
"BillToAddr": "GGGGGGGGG",
"BCity": "New Iberia",
"BState": "LA",
"BZip": "70560",
"WHAddr": "Perry",
"WHCity": "New Iberia",
"WHState": "LA",
"WHZip": "70560"
}
Using the above I want create a view that displays user information like:
Name {Name from the store}
AccountManager Last NAme {AcctManagLast from the store}
I am new to Sencha . Plese help me how to write form that displays the label followed by value from store.

A simple panel with template and data will work for you, check out : http://www.senchafiddle.com/#KmNX8#yqVQt

Related

Calendar Ant Design: How to show events with variable dates?

I am looking for a way to show events in an Ant Desing Calendar using dateCellRender with the dates from an variable object, like this one:
[
{
"id": 1,
"content": "Example",
"date": "01/05/2022",
"horario": [
"2022-05-26T06:00:00.925Z",
"2022-05-26T07:00:00.478Z"
],
},
{
"id": 2,
"content": "Example",
"date": "08/05/2022",
"horario": [
"2022-05-26T11:00:00.859Z",
"2022-05-26T14:00:00.976Z"
],
}
]
The normal way to show events is using a switch, like you can see in this CodeSandbox from AntD: https://codesandbox.io/s/ruj266
My object comes from the backend and will always change, there is a way to show dynamic events using that object?
Since antd calendar works with moment object, so when you try to render the calendar, you can covert the value of current date to string by using format method of moment object like this:
<Calendar dateCellRender={(value) => {
const stringValue = value.format("DD/MM/yyyy");
return (...);
};} />;
and compare the result of format method with date values in your data, I implemented an example by using of your data example here on codesandbox:
antd-calendar-example
is this what you are looking for?

Generating nested streamblocks content programmatically in Wagtail

Currently struggling to generate content programmatically for the following StreamBlock:
class SpecialistStreamBlock(blocks.StreamBlock):
accordion = SpecialistAccordionBlock()
class SpecialistAccordionBlock(BaseBlock):
content = StreamBlock([
('accordion_item', StructBlock([
('title', blocks.CharBlock(label=_(u"Title"), max_length=255)),
('content', LeanRichTextBlock()),
])),
], label=_(u"Accordion"))
In the case the structure is not nested is done using tuples like ("variablename for block definition", {dict with key value for defined fields}) but this approach doesn't seems to work in case of nested structures.
What I have tried so far without success:
accordion_block = ("accordion", {"title": "Some title",
"content": ("accordion_item",
{"title": "Another title",
"content": RichText(education_block_str)})})

Angular // ng-select Use interpolation within a textarea on a text pulled from an array

Still in my very first days with Angular and ran into a problem i can't get my head around.
What I am trying to accomplish is sort of creating a way to have a persons name added to a message template.
The templates are loaded from a file like this
this.http.get('../../assets/templatefiles/customtemplates.json').subscribe(data => {this.templateArray = data as any [];
The structure of the JSON file is as follows
[{
"Id": 1,
"Type": "SR Templates",
"Name": "Message 1",
"Body": "Some meaningful text here"
},
{
"Id": 2,
"Type": "SR Templates",
"Name": "Message 2",
"Body": "Some more meaningful text here"
},
{
"Id": 3,
"Type": "GTFO Templates",
"Name": "Message 3",
"Body": "Guess what? Exactly, some even more..blahhh"
}]
All good so far. Then, in my template I use ng-select to create the dropdown list to display the options grouped by Type
<ng-select [items]="templateArray"
bindLabel="Name"
bindValue="Body"
groupBy="Type"
[(ngModel)]="selectedTemplate"
>
<ng-template ng-optgroup-tmp let-item="item">
<strong>{{item.Id}}</strong>
</ng-template>
</ng-select>
So far...working it seems. Templates are grouped by Type and show up in the drop down just fine.
Below the selection is a textarea in which the "Body" value is supposed to be displayed. Works fine as well, when selecting a template from the drop down the text shows fine in the textarea.
The problem I am facing is that there is an input field for the persons name the message will be send to.
I get the name as follows:
<input type="text" [(ngModel)]="srcName" class="form-control" placeholder="Name">
The bit confusing me is how to get/add the persons name to the message using interpolation?
I was hoping for something like just having to change the text in the JSON and adding the interpolation to it but apparently that does not work hehe.
{
"Id": 1,
"Type": "SR Templates",
"Name": "Message 1",
"Body": "Dear {{srcName}, Some meaningful text here"
}
I've been searching up and down, but am ultimately stuck and am desperate for a nudge in the direction I would have to go to actually get that name inserted in the textarea together with the template from the array...
You can make a function that concatenates your selected template and the name in you input, like so:
onSubmit() {
this.message = `Dear ${this.srcName}, ${this.selectedTemplate}`;
}
And then you can add a button that executes this function:
<button (click)="onSubmit()">Submit</button>
Now whenever you select the template you want and add the name you want to the input and click on submit button, you will get a concatenated message with the info you want.
Here is a live demo if you want more explanation.
In the live demo a used a normal HTML select, but it should work the same with angular material select.
##EDIT
If you need to put your srcName inside of your templates body, you will have to create a place holder in your template's body, something like:
"Guess what? Exactly {srcName}, some even more..blahhh"
instead of:
"Guess what? Exactly, some even more..blahhh"
Then you will have to change the onSubmit function:
onSubmit() {
this.message = this.selectedTemplate.replace('{srcName}', this.srcName)
}
I also added the changes to to the live demo.

Add to all elements from an attributes something

I have a collection which contains insides these attributes:
_id, title, year, country. By the way the collection name is movies and it's a Json.
I would like to add before all titles of the document that:
"The title is: NameOfTheTitleHere "
For example I have that:
{"_id": 1,"title": "Gozilla", "year":1998, "country": "USA"}.
And I want that: {"_id": 1,"title": "The title is: Gozilla", "year":1998, "country": "USA"}.
I searched on the doc and the net but I can't find anything. Could someone help me please.
Thanks in avance for anybody who would take the time to help me.
Since MongoDB v4.2, db.collection.update allows conditional updates based on current field values or updating one field using the value of another field(s).
db.movies.update({},
[
{$set:{title:{$concat:["The title is:", " ", "$title"]}}}
],
{multi:true})
Before v4.2, we need to perform MongoDB aggregation and override collection with $out operator:
db.movies.aggregate([
{
$addFields: {
"title" : { $concat: ["The title is:", " ", "$title"] }
}
},
{ $out: "movies" }
])

Association ExtJs MVC 4.2

ExtJS 4.2 MVC: I have two models ServiceM and CommentsM. ServiceM has association(hasmany) with CommentsM. I DIDNOT forget to add the requires section ServiceM. Proxy is an ajax type defined in the model itself. I also created stores for each. Coming to the view, I have a grid for viewing all the services which are derived on loading the application. itemdblclick event is used to provide a detailed view about the service which is a window extending a form. The form is popullated by the below code:
var ServiceDetailV = Ext.widget('alias name of the service detail view');
ServiceDetailV.down('form').getForm().loadRecord(record);
I have two questions here.
When using developer tools in google chrome, in the above code I place debugger; at the end. I have highlighted the record, right clicked and evaluated that part. I see the data part and raw part. what is this raw part. It has all the data which the server is giving me(payload), even the nested comments section which is associated with the Service data.
I am able to popullate the fields in the form, but not the list of comments. the list of comments goes into a panel present in the form. How can I popullate the comments section.
JSON data:
{
"data": [
{
"id": 1,
"x": "some text",
"q": "some text",
"a": "some text",
"r":"some text",
"comments": [
{
"id": 87,
"commentDate": "date",
"description": "some text"
},
{
"id": 86,
"commentDate": "date",
"description": "some text"
}
]
} "total": 1,
"success": true}
Now, how can i access the comments field and poppulate the form with this data?
Please shed some knowledge on Associations ExtJs MVC.
Cheers!
Well, I took a step and got the solution for this. the raw parameter actually has the raw JSON payload. In the controller part I have handled it via a select event.
onSelectIssueShowComments : function(selection,record, index, eOpts) {
this.getComments().setRecord(record.raw);
}
I the view part
tpl : [ '<p>Previous Comments: ', '<tpl for="comments">',
'<p>{#}. {description} {commentDate}</p>', '</tpl></p>' ],
setRecord : function(record) {//this record here is record.raw
this.record = record;
if (record) {
this.update(record);
} else {
this.update(' ');
}
}
So it displays the array of comments in a Panel.

Resources