Sencha Touch Accordion items blank - layout

Im using the Accordion Layout for Sencha Touch 1.0.1 from Mitchell Simoens git link :
https://github.com/mitchellsimoens/Ext.layout.AccordionLayout
I want to put a form panel into one of the accordion items. But although the html in the formPanel shows, when I add items to the panel it goes blank.
Help please!!
My code :
var formp = new Ext.form.FormPanel({
scroll : "vertical",
title : "List Test",
// scrollable : true,
items : [
{
xtype : 'textfield',
label : 'hello',
id : 'hello',
name : 'hello'
}
]
});
var panel = new Ext.Panel({
fullscreen : true,
scroll : "vertical",
layout : {
type : "accordion"
},
minHeight : 300,
items: [
{ xtype : "panel", title : "One Title", html : "One" },
list,
{ xtype : "panel", title : "Three Title", html : "Three" },
{ xtype : "panel", title : "Four Title", html : "Four" },
{ xtype : "panel", title : "Five Title", html : "Five" },
{ xtype : "panel", title : "Six Title", html : "Six" }
]
});

i have updated this library to fix some problems that i encountered working with this layout, so you can check if this solves your problem
http://pastebin.com/fGRMBMfn
Update:
new Ext.Application({
launch : function() {
var panel = new Ext.Panel({
fullscreen : true,
scroll : "vertical",
layout : {
type : "accordion"
},
minHeight : 300,
renderTo : Ext.getBody(),
items: [
{ xtype : "panel", title : "One Title", html : "One" },
{ xtype : "panel", title : "Three Title", html : "Three" },
{ xtype : "panel", title : "Four Title", html : "Four" },
{ xtype : "panel", title : "Five Title", html : "Five" },
{ xtype : "panel", title : "Six Title", html : "Six" }
]
});
}
});

Related

mongo : update property of specific element in array

I have this collection :
{
"_id" : ObjectId("5ac69e90a9d1a5f3e01a5233"),
"category": "spain",
"products" : [
{
"label" : "uno"
},
{
"label" : "dos"
},
{
"label" : "tres"
}
]
},
{
"_id" : ObjectId("5ac69e90a9d1a5f3e01a5234"),
"category": "england",
"products" : [
{
"label" : "one"
},
{
"label" : "two"
},
{
"label" : "three"
}
]
}
I want to do the following operation : update the label from "one" to "four" of the object with the category england. But I have some troubles to design the most elegant and performant solution :
first solution : I could copy paste and rewrite the entire document with just replacing the one by four
second solution where I struggle : I would like to find the element with label equals to one and updates it to four, but I don't know how to do. I don't want to use mongo path index like 'products.O.label' because I can't garantee that the product with label one will be at position 0 in the products array.
Thanks in advance
You could use this one:
db.collection.updateMany(
{ category: "england" },
{ $set: { "products.$[element].label": "four" } },
{ arrayFilters: [{ "element.label": "one" }] }
)
If you prefer and aggregation pipeline it would be this one:
db.collection.updateMany(
{ category: "england" },
[{
$set: {
products: {
$map: {
input: "$products",
in: {
$cond: {
if: { $eq: ["$$this.label", "one"] },
then: { label: "four" },
else: "$$this"
}
}
}
}
}
}]
)
but it might be an overkill, in my opinion.
Further, referring to #Wernfried Domscheit, another way using aggregation.
> db.catg1.find();
{ "_id" : ObjectId("5ac69e90a9d1a5f3e01a5233"), "category" : "spain", "products" : [ { "label" : "uno" }, { "label" : "dos" }, { "label" : "tres" } ] }
{ "_id" : ObjectId("5ac69e90a9d1a5f3e01a5234"), "category" : "england", "products" : [ { "label" : "four" }, { "label" : "two two" }, { "label" : "three" } ] }
> db.catg1.aggregate([
... {$unwind:"$products"},
... {$match:{category:"england",
... "products.label":"four"
... }
... },
... ]).forEach(function(doc){
... print(doc._id);
... db.catg1.update(
... {"_id":doc._id},
... { $set:{"products.$[element].label":"one"}},
... {arrayFilters: [{"element.label":"four"}]}
... );
... });
ObjectId("5ac69e90a9d1a5f3e01a5234")
> db.catg1.find();
{ "_id" : ObjectId("5ac69e90a9d1a5f3e01a5233"), "category" : "spain", "products" : [ { "label" : "uno" }, { "label" : "dos" }, { "label" : "tres" } ] }
{ "_id" : ObjectId("5ac69e90a9d1a5f3e01a5234"), "category" : "england", "products" : [ { "label" : "one" }, { "label" : "two two" }, { "label" : "three" } ] }
> db.version();
4.2.6
>

Appending to list works in MongoDB shell, but not in Node,js

This is the structure of the file.
{
"_id" : ObjectId("5f45274bbbe768fe0d56d9d0"),
"article" : "article-name",
"comments" : [
{
"id" : "_lj7cfhx7z",
"name" : "person",
"date" : "25/08/2020",
"text" : "asdasdsddsdsdasd",
"replies" : [
{
"name" : "person2",
"date" : "25/08/2020",
"text" : "replyyyteextttttt"
},
{
"name" : "person3",
"date" : "25/08/2020",
"text" : "replyyyteextttttt"
}
]
},
{
"id" : "_wpdpj7kv6",
"name" : "person4",
"date" : "25/08/2020",
"text" : "aaaa",
"replies" : [ ]
}
]
}
I am trying to write a function that appends to replies list given the id of the comment. When I do it in the MongoDB shell like this db.comments.findOneAndUpdate({"article": "exif-parsing", "comments.id": "_t2aqbhi5a"}, {"$push": {"comments.$.replies": {"text": "new"}}});, it works. But in Node.js it doesn't work.
var db = new DataBase("mongodb://localhost:27017/")
replyTo(article, id, name, comment) {
db.connect("blog", "comments", function(collection) {
var reply = {name: name, date: getCurrentDate(), text: comment};
collection.findOneAndUpdate({"article": article, "comments.id": id}, {"$push": {"comments.$.replies": reply}});
});
}

How to push new field in array mongodb

Imagine I have database like
{
"_id" : ObjectId("594994d1ab6c161168aa5969"),
"user_id" : ObjectId("594994d1ab6c161168aa5968"),
"active" : [
{
"type" : "active"
},
{
"type" : "inactive"
}
]
}
I want add to first object in active array . Here is result I expected
{
"_id" : ObjectId("594994d1ab6c161168aa5969"),
"user_id" : ObjectId("594994d1ab6c161168aa5968"),
"active" : [
{
"type" : "active",
"note": [{
content: 'here is content',
title : ' here is title'
}]
},
{
"type" : "inactive"
}
]
}
Here is code I tried
db.collection('..').update({'user_id' : ObjectId(userId)} ,
{$push:{ "active.0": "note": [{
content: 'here is content',
title : ' here is title'
}] } )
But I get The field 'active.0' must be an array but is of type object in document . Where is my wrong ? Please help
Starting with your document like this:
{
"_id" : ObjectId("594994d1ab6c161168aa5969"),
"user_id" : ObjectId("594994d1ab6c161168aa5968"),
"active" : [
{
"type" : "active"
},
{
"type" : "inactive"
}
]
}
You run the $push like this:
db.collection.update(
{ "_id" : ObjectId("594994d1ab6c161168aa5969") },
{ "$push":{ "active.0.note": { content: 'here is content', title : ' here is title' } } }
)
Which creates the new array within the first element like so:
{
"_id" : ObjectId("594994d1ab6c161168aa5969"),
"user_id" : ObjectId("594994d1ab6c161168aa5968"),
"active" : [
{
"type" : "active",
"note" : [
{
"content" : "here is content",
"title" : " here is title"
}
]
},
{
"type" : "inactive"
}
]
}
Everything here is cut and paste from my shell.

Query work in mongo cmd but not in calling method

I am working in mongodb.
I write a query
db.ekgs.find({_id: ObjectId("54cd1dd3adc274b20a7f650d"),"interpretationList.interpretations" : { $all:[[ObjectId("54c09fb3581c4c8c218d1a39"),ObjectId("54c09fb3581c4c8c218d1a3a")]]}})
it work in mongo cmd.
but when i write this in a method that take input from user then it doesn't work.
req.body contain:
{
"ekgId":"54cdaed7adc274b20a7f650e",
"diagnosis":
[
"54c09fb3581c4c8c218d1a39",
"54c09fb3581c4c8c218d1a3a"
]
};
and in my method i write
modalSchema.find({"_id": req.body.ekgId,'interpretationList.interpretations' :{ $all :req.body.diagnosis , $size: arrLength }});
it always return null.
schema collection:
{
"_id" : ObjectId("54cdaed7adc274b20a7f650e"),
"title" : "Demo Ekg",
"description" : "Demo Description",
"diagnosis" : "Demo Diagnosis",
"ekgImageExtension" : "jpg",
"urgency" : "Demo Urgency",
"therapy" : "Demo Therapy",
"differentialDiagnosis" : "Demo Ddx",
"history" : "Demo History",
"references" : "Demo References",
"fileName" : "",
"imageURL" : "images/Ekgs/54c09d68581c4c8c218d1a38/54c09d68581c4c8c218d1a38.jpg",
"interpretationList" : {
"interpretations" : [
ObjectId("54c09fb3581c4c8c218d1a39"),
ObjectId("54c09fb3581c4c8c218d1a3a")
]
},
"tags" : [
{
"_id" : ObjectId("54c255da581c4c8c218d2397"),
"tagName" : "Tag 1"
}
],
"segment" : [
{
"explanation" : "Demo Explanation 1",
"fileName" : "",
"imageURL" : "",
"level" : {
"_id" : ObjectId("54c25616581c4c8c218d2398"),
"levelName" : "Level 1"
}
},
{
"explanation" : "Demo Explanation 2",
"fileName" : "",
"imageURL" : "",
"level" : {
"_id" : ObjectId("54c25616581c4c8c218d2398"),
"levelName" : "Level 1"
}
}
]
}
You should convert all the elements of the diagnosis array in the request object to ObjectIds instead of strings. Then execute your query on Mongo
here is a code snippet to convert an array of strings into an array of ObjectIds
var result = interpretationList.interpretations.map(function (x) {
return ObjectId(x);
});
then in your query you use the result object instead of req.body.diagnosis
modalSchema.find({"_id": ObjectId(req.body.ekgId),'interpretationList.interpretations' :{ $all :result , $size: arrLength }});

Update and/or add array element properties using req.body via Mongoose?

I have the following document:
{
"_id" : ObjectId("503b83dfad79cc8d26000004"),
"pdfs" : [
{
"title" : "Test document",
"pdf_id" : ObjectId("504f6793ce351a595d000004"),
"created_at" : ISODate("2012-09-11T16:32:19.276Z")
},
{
"title" : "Some other doc",
"pdf_id" : ObjectId("502bf124b4642341230003f0"),
"created_at" : ISODate("2012-09-11T11:34:19.276Z")
}
]
}
Now in an incoming form via req.body, I have 2 fields: title and description.
I want to update title and insert description for a specified pdf_id, how do I do that?
So in the end, my document will now look like:
{
"_id" : ObjectId("503b83dfad79cc8d26000004"),
"pdfs" : [
{
"title" : "This is an UPDATED title",
"description" : "It has an ALL NEW description",
"pdf_id" : ObjectId("504f6793ce351a595d000004"),
"created_at" : ISODate("2012-09-11T16:32:19.276Z")
},
{
"title" : "Some other doc",
"pdf_id" : ObjectId("502bf124b4642341230003f0"),
"created_at" : ISODate("2012-09-11T11:34:19.276Z")
}
]
}
Just to be clear, I'm really just looking for the Mongoose update syntax.
You can use the $ positional operator to refer to the matched pdfs array element in your $set:
Model.update(
{ 'pdfs.pdf_id': pdf_id },
{ $set: {
'pdfs.$.title': title,
'pdfs.$.description': description
}}, function (err, numAffected) { ... }
);

Resources