sencha hbox panel not displayed - layout

I am trying to create an hbox which displays 2 panels.It was working fine until I decided to make the layout of the left panel as "CARD".
The code i used for that is
Ext.define("InfoImage.view.WorkItems", {
layout:'hbox',
extend:'Ext.Container',
requires:[
'Ext.TitleBar',
'Ext.layout.HBox',
'Ext.List'
],
xtype:'workitems',
id:'workitems',
// layout:'fit',
config:{
//scrollable:'true',
fullscreen:true,
layout:'fit',
cls:'hboxpanel',
items:[
{
xtype:'leftPanel'
},
{
xtype:'documentPanel'
}
]
}
});
The left panel code is given below:
Ext.define('InfoImage.view.leftPanel', {
extend:'Ext.Panel',
requires:[
'InfoImage.view.Main',
'InfoImage.view.WorkItems',
'Ext.TitleBar'
],
id:'leftPanel',
xtype:'leftPanel',
config:{
width:'30%',
fullscreen:true,
autoScroll:true,
layout:'card',
cardSwitchAnimation:'slide',
cls:'leftPanel',
items:[
/*{
xtype:'workItemPanel'
},
{
xtype:'inboxQueuePanel'
},*/
{
xtype:'toolbar',
docked:'bottom',
items:[
{
xtype:'button',
cls:'workitem',
text:"<img src='resources/images/compose.png' style='width:40px;height:40px;' />",
iconMask:true,
ui:'normal',
id:'workitem',
handler:function () {
}
},
{
xtype:'button',
cls:'inbox',
text:"<img src='resources/images/mail.png' style='width:40px;height:40px;' />",
iconMask:true,
ui:'normal',
id:'inbox',
handler:function () {
}
},
{
xtype:'button',
cls:'filecabinet',
text:"<img src='resources/images/cabinet_256.jpg' style='width:40px;height:40px;' />",
iconMask:true,
ui:'normal',
id:'filecabinet',
handler:function () {
}
}
]
}
]
}
});
My problem is that when i run the project, only right panel is displayed. How do i get to fix the leftPanel problem?

I think what you're asking for is to have the leftPanel switch between
one of three 'card' tabs? This is like the Sencha
GeoCongress example (it's full screen though) that
they ship in their examples directory. In the app/controller/SplashScreen.js file, they have several functions that call setActiveItem() to set the card. You can do the same in your handlers:
handler:function () {
var leftPanel = Ext.getCmp('leftPanel'); // Get the Left Panel's id
leftPanel.setActiveItem(Ext.getCmp('workItemPanel')); // get the id of the card and make it active
}
Here's my working version of InfoImage.view.LeftPanel
Ext.define('InfoImage.view.LeftPanel', {
extend:'Ext.Panel',
requires:[
'InfoImage.view.Main',
'InfoImage.view.WorkItems',
'Ext.TitleBar'
],
id:'leftPanel',
xtype:'leftPanel',
config:{
width:'30%',
fullscreen:true,
autoScroll:true,
layout: {
type: 'card',
animation: {
type: 'slide'
}
},
cls:'leftPanel',
items:[
{
xtype:'toolbar',
docked: 'bottom',
items:[
{
xtype:'button',
cls:'workitem',
html:"1 <img src='resources/images/compose.png' style='width:20px;height:20px;'/>",
iconMask:true,
ui:'normal',
id:'workitem',
handler:function () {
var leftPanel = Ext.getCmp('leftPanel');
leftPanel.setActiveItem(Ext.getCmp('one'));
}
},
{
xtype:'button',
cls:'inbox',
text:"2 <img src='resources/images/mail.png' style='width:40px;height:40px;' />",
iconMask:true,
ui:'normal',
id:'inbox',
handler:function () {
var leftPanel = Ext.getCmp('leftPanel');
leftPanel.setActiveItem(Ext.getCmp('workItemPanel'));
}
},
{
xtype:'button',
cls:'filecabinet',
text:"3 <img src='resources/images/cabinet_256.jpg' style='width:40px;height:40px;' />",
iconMask:true,
ui:'normal',
id:'filecabinet',
handler:function () {
var leftPanel = Ext.getCmp('leftPanel');
leftPanel.setActiveItem(Ext.getCmp('inboxQueuePanel'));
}
}
]
},
{
xtype: 'panel',
id: 'one',
html:'one'
},
{
xtype: 'panel',
id: 'workItemPanel',
html:'workItemPanel'
},
{
xtype: 'panel',
id: 'inboxQueuePanel',
html:'inboxQueuePanel'
}
]
}
});

Related

Vuetify treeview search behavior

Hello and Happy new Year guys,
Again I ask about v-treeview search. When I do my filter, the behavior do not satisfy me.
I updated my version of vuetify to 1.4.0. And I'm using vue 2.5.15
https://codepen.io/anon/pen/PXeMmy?&editors=101
HTML
<div id="app">
<v-container grid-list-md>
<v-layout wrap>
<v-flex xs6>
<!-- Search Field -->
<v-text-field label="search" v-model="search" box>
</v-text-field>
<!-- Treeview -->
<v-treeview :items="filteredTree"
v-model="selected"
active-class="grey lighten-4 indigo--text"
item-key="name"
selected-color="blue"
selectable
hoverable>
</v-treeview>
</v-flex>
<v-flex xs6>
<v-chip v-for="(s , i) in selected" :key="i">
{{s}}
</v-chip>
</v-flex>
</v-layout>
</v-container>
</div>
JS :
new Vue({
el: '#app',
data(){
return{
search: '',
tree: [
{
id: 1,
name: 'Applications',
children: [
{ id: 2, name: 'Calendar' },
{ id: 3, name: 'Chrome' },
{ id: 4, name: 'Webstorm' }
]
},
{
id: 5,
name: 'Languages',
children: [
{ id: 6, name: 'English' },
{ id: 7, name: 'French' },
{ id: 8, name: 'Spannish' }
]
}
],
selected: []
}
},
computed:{
filteredTree: {
get: function() {
let regexp = new RegExp(this.search, "i")
return this.filterTree(this.tree, regexp) || []
},
},
},
methods: {
filterTree: function(tree, filter) {
if (!Array.isArray(tree)) return null
return JSON.parse(JSON.stringify(tree)).filter(function matchName(o) {
let temp;
if (o.name.match(filter)) {
return true;
}
if (!Array.isArray(o.children)) {
return false;
}
temp = o.children.filter(matchName);
if (temp.length) {
o.children = temp;
return true;
}
});
}
}
})
In this exemple when I search "Calen", only "Application -> Calendar" is visible. Until now, it's what I want.
But when I select Calendar, "Application" is also selected; and when I clear the filter, all the children of "Application" are selected too. And I'd like to select "Calendar" and when I clear I don't want its siblings to be selected.
Thank you for reading

How do I populate a User Story's Revision History in a grid

I found an answer related to Revision History "Querying for User Story revisions in Rally"
I am having trouble determining how to populate a grid with it.
Can I use the model and populate a story that the gird references?
Here is a working example, using other examples.
I had to populate an array with revision history info and add it to a story.
Then the story populated the grid.
// Also referenced
// https://stackoverflow.com/questions/22334745/does-rally-data-custom-store-have-magic-uniqueness
//
Ext.define('CustomApp',
{
extend: 'Rally.app.App',
componentCls: 'app',
launch: function()
{
var panel = Ext.create('Ext.panel.Panel',
{
layout: 'hbox',
itemId: 'parentPanel',
componentCls: 'panel',
items: [
{
xtype: 'panel',
title: 'Artifacts updated in the last two days',
width: 600,
itemId: 'childPanel1'
},
{
xtype: 'panel',
title: 'Last Revision',
width: 600,
itemId: 'childPanel2'
}]
});
this.add(panel);
var artifacts = Ext.create('Rally.data.wsapi.artifact.Store',
{
models: ['UserStory','Defect', 'TestCase'],
fetch: ['Owner', 'FormattedID','Name','ScheduleState','RevisionHistory','Revisions','Description','CreationDate','User'],
autoLoad: true,
listeners:
{
load: this._onDataLoaded,
scope: this
}
});
},
_onDataLoaded: function(store, data)
{
this._customRecords = [];
_.each(data, function(artifact, index)
{
this._customRecords.push(
{
_ref: artifact.get('_ref'),
FormattedID: artifact.get('FormattedID'),
Name: artifact.get('Name'),
RevisionID: Rally.util.Ref.getOidFromRef(artifact.get('RevisionHistory')),
RevisionNumber: 'not loaded'
});
}, this);
this._createGrid(store,data);
},
_createGrid: function(store,data)
{
var that = this;
var g = Ext.create('Rally.ui.grid.Grid',
{
itemId: 'g',
store: store,
enableEditing: false,
showRowActionsColumn: false,
columnCfgs:
[{text: 'Formatted ID', dataIndex: 'FormattedID'},
{text: 'Name', dataIndex: 'Name'},
{text: 'ScheduleState', dataIndex: 'ScheduleState'},
{text: 'Last Revision',
renderer: function (v, m, r)
{
var id = Ext.id();
Ext.defer(function ()
{
Ext.widget('button',
{
renderTo: id,
text: 'see',
width: 50,
handler: function ()
{
that._getRevisionHistory(data, r.data);
}
});
}, 50);
return Ext.String.format('<div id="{0}"></div>', id);
}
}], height: 400,
});
this.down('#childPanel1').add(g);
},
_getRevisionHistory: function(artifactList, artifact)
{
this._artifact = artifact;
this._revisionModel = Rally.data.ModelFactory.getModel(
{
type: 'RevisionHistory',
scope: this,
success: this._onModelCreated
});
},
_onModelCreated: function(model)
{
model.load(Rally.util.Ref.getOidFromRef(this._artifact.RevisionHistory._ref),
{
scope: this,
success: this._onModelLoaded
});
},
_onModelLoaded: function(record, operation)
{
var list = [];
record.getCollection('Revisions').load(
{
fetch: true,
scope: this,
callback: function(revisions, operation, success)
{
_.each(revisions, function(artifact, index)
{
var creationdate;
if (Rally.environment.useSystemTimezone || Rally.environment.useWorkspaceTimeZone)
{
creationdate = Rally.util.DateTime.formatDate(artifact.data.CreationDate, true);
}
else
{
creationdate = Rally.util.DateTime.formatWithDefaultDateTime(artifact.data.CreationDate);
}
var nodedata =
{
rev_num: artifact.data.RevisionNumber,
descript: artifact.data.Description,
author: artifact.data.User._refObjectName,
creationdate: creationdate
};
if(nodedata.descript.indexOf('SCHEDULE STATE') > -1)
{
list.push(nodedata);
}
else
{
if(nodedata.descript .indexOf('PLAN ESTIMATE') > -1)
{
list.push(nodedata);
}
}
}, this);
var myStore = Ext.create("Rally.data.custom.Store",
{
autoLoad: true,
data : list,
});
var revGrid = Ext.create('Rally.ui.grid.Grid',
{
itemId: 'revGrid ',
store: myStore,
enableEditing: false,
showRowActionsColumn: false,
height: 400,
columnCfgs:
[
{text: 'Rev #', dataIndex: 'rev_num'},
{text: 'Description', dataIndex: 'descript'},
{text: 'Author', dataIndex: 'author'},
{text: 'Change Date', dataIndex: 'creationdate'}
]
});
this.down('#childPanel2').add(revGrid);
}
});
},
});

js grid and autocomplete

I am able to create a custom field with jsGrid and jquery autocomplete. All ajax CRUD calls are working for all other fields. The below code activates autocomplete and shows the available options in the input field as expected.
var tags = ["tag1", "tag2", "tag3"];
MyDescriptionField.prototype = new jsGrid.Field({
insertTemplate: function(value) {
return this._editPicker = $("<input>").autocomplete({source : tags});
},
editTemplate: function(value) {
return this._editPicker = $("<input>").autocomplete({source : tags});
},
........... (more code)
So far so good. However to actually capture the value so it can be inserted into the db, I also need to define insertValue and editValue.
The code below is NOT working
insertValue: function(){
return this._insertPicker = $("<input>").val();
},
...........(more code)
this one is not working eiter:
insertValue: function(){
return this._insertPicker.autocomplete({
select: function(event, ui) {
$("<input>").val(ui.item.value);
}
});
},
reference: jsGrid. http://js-grid.com/demos/
autocomplete: https://jqueryui.com/autocomplete/
Try this snippet:
$(function() {
var myTagField = function(config) {
jsGrid.Field.call(this, config);
};
myTagField.prototype = new jsGrid.Field({
sorter: function(tag1, tag2) {
return tag1.localeCompare(tag2);
},
itemTemplate: function(value) {
return value;
},
insertTemplate: function(value) {
return this._insertAuto = $("<input>").autocomplete({source : tags});
},
editTemplate: function(value) {
return this._editAuto = $("<input>").autocomplete({source : tags}).val(value);
},
insertValue: function() {
return this._insertAuto.val();
},
editValue: function() {
return this._editAuto.val();
}
});
jsGrid.fields.myTagField = myTagField;
$("#jsGrid").jsGrid({
width: "100%",
inserting: true,
editing: true,
sorting: true,
paging: true,
fields: [
{ name: "Name", type: "text" },
{ name: "Tag", type: "myTagField", width: 100, align: "center" },
{ type: "control", editButton: false, modeSwitchButton: false }
],
data: db.users
});
});
var tags = ["tag1", "tag2", "tag3"];
var db = {};
db.users = [
{
"Name": "Carson Kelley",
"Tag": ""
},
{
"Name": "Prescott Griffin",
"Tag": "tag1"
},
{
"Name": "Amir Saunders",
"Tag": "tag3"
},
{
"Name": "Derek Thornton",
"Tag": "tag2"
},
{
"Name": "Fletcher Romero",
"Tag": ""
}];
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="//rawgit.com/tabalinas/jsgrid/master/dist/jsgrid.min.js"></script>
<link href="//code.jquery.com/ui/1.11.2/themes/cupertino/jquery-ui.css" rel="stylesheet"/>
<link href="//rawgit.com/tabalinas/jsgrid/master/dist/jsgrid.min.css" rel="stylesheet"/>
<link href="//rawgit.com/tabalinas/jsgrid/master/dist/jsgrid-theme.css" rel="stylesheet"/>
<div id="jsGrid"></div>
or this codepen: https://codepen.io/beaver71/pen/rpaLEo
Thanks #beaver. Your pen helped my understand custom fields better. I extended it a bit to add filtering with autocomplete. https://codepen.io/obrienje/pen/aQKNry
$(function() {
var myTagField = function(config) {
jsGrid.Field.call(this, config);
};
myTagField.prototype = new jsGrid.Field({
autosearch: true,
sorter: function(tag1, tag2) {
return tag1.localeCompare(tag2);
},
itemTemplate: function(value) {
return '<span class="label label-primary">' + value + '</span>';
},
insertTemplate: function(value) {
return this._insertAuto = $("<input>").autocomplete({
source: tags
});
},
filterTemplate: function(value) {
if (!this.filtering)
return "";
var grid = this._grid,
$result = this._filterAuto = $("<input>").autocomplete({
source: tags
});
if (this.autosearch) {
$result.on("change", function(e) {
grid.search();
});
}
return $result;
},
editTemplate: function(value) {
return this._editAuto = $("<input>").autocomplete({
source: tags
}).val(value);
},
insertValue: function() {
return this._insertAuto.val();
},
filterValue: function() {
return this._filterAuto.val();
},
editValue: function() {
return this._editAuto.val();
}
});
jsGrid.fields.myTagField = myTagField;
$("#jsGrid").jsGrid({
width: "100%",
filtering: true,
inserting: true,
editing: true,
sorting: true,
paging: true,
fields: [{
name: "Name",
type: "text"
},
{
name: "Tag",
type: "myTagField",
width: 100,
align: "center"
},
{
type: "control",
editButton: false,
modeSwitchButton: false
}
],
data: db.users,
controller: {
loadData: function(filter) {
return $.grep(db.users, function(item) {
return (!filter.Tag || item.Tag.toLowerCase().indexOf(filter.Tag.toLowerCase()) > -1);
});
}
}
});
});
var tags = ["tag1", "tag2", "tag3"];
var db = {};
db.users = [{
"Name": "Carson Kelley",
"Tag": ""
},
{
"Name": "Prescott Griffin",
"Tag": "tag1"
},
{
"Name": "Amir Saunders",
"Tag": "tag3"
},
{
"Name": "Derek Thornton",
"Tag": "tag2"
},
{
"Name": "Fletcher Romero",
"Tag": ""
}
];
<html>
<head>
<link href="https://rawgit.com/tabalinas/jsgrid/master/dist/jsgrid.min.css" rel="stylesheet"/>
<link href="https://rawgit.com/tabalinas/jsgrid/master/dist/jsgrid-theme.css" rel="stylesheet"/>
<link href="//code.jquery.com/ui/1.11.2/themes/cupertino/jquery-ui.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css"/>
</head>
<body>
<h1>Custom Grid DateField filtering with autocomplete</h1>
<div id="jsGrid"></div>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="https://rawgit.com/tabalinas/jsgrid/master/dist/jsgrid.min.js"></script>
</body>
</html>
Thanks #beaver. Your pen helped my understand custom fields better. I extended it a bit to add filtering with autocomplete. https://codepen.io/obrienje/pen/aQKNry

pimcore workflow management - disabling Save and publish

In pimcore I tried implementing the workflow management for objects. Workflow is working fine. But, save and publish button are still appearing, how can I remove these features if workflow is enabled. 1. Disabling Save, publish, unpublish and delete to the user if workflow is enabled. 2. Removing same options (save, publish, unpublish and delete) on right clicking the object.
If you want to disable buttons you have to overwrite pimcore object.js(pimcore/static6/js/pimcore/object/object.js) and tree.js(pimcore/static6/js/pimcore/object/tree.js).
First create plugin. Then create object.js in static(Remember to add js paths to plugin.xml) and add code:
pimcore.registerNS("pimcore.object.object");
pimcore.object.object = Class.create(pimcore.object.object, {
getLayoutToolbar : function () {
if (!this.toolbar) {
var buttons = [];
this.toolbarButtons = {};
this.toolbarButtons.save = new Ext.SplitButton({
text: t('save'),
iconCls: "pimcore_icon_save",
scale: "medium",
handler: this.save.bind(this, "unpublish"),
menu:[{
text: t('save_close'),
iconCls: "pimcore_icon_save",
handler: this.unpublishClose.bind(this)
}]
});
this.toolbarButtons.publish = new Ext.SplitButton({
text: t('save_and_publish'),
iconCls: "pimcore_icon_publish",
scale: "medium",
handler: this.publish.bind(this),
menu: [{
text: t('save_pubish_close'),
iconCls: "pimcore_icon_save",
handler: this.publishClose.bind(this)
},
{
text: t('save_only_new_version'),
iconCls: "pimcore_icon_save",
handler: this.save.bind(this, "version")
},
{
text: t('save_only_scheduled_tasks'),
iconCls: "pimcore_icon_save",
handler: this.save.bind(this, "scheduler","scheduler")
}
]
});
this.toolbarButtons.unpublish = new Ext.Button({
text: t('unpublish'),
iconCls: "pimcore_icon_unpublish",
scale: "medium",
handler: this.unpublish.bind(this)
});
this.toolbarButtons.remove = new Ext.Button({
tooltip: t("delete"),
iconCls: "pimcore_icon_delete",
scale: "medium",
handler: this.remove.bind(this)
});
this.toolbarButtons.rename = new Ext.Button({
tooltip: t('rename'),
iconCls: "pimcore_icon_key pimcore_icon_overlay_go",
scale: "medium",
handler: function () {
var options = {
elementType: "object",
elementSubType: this.data.general.o_type,
id: this.id,
default: this.data.general.o_key
};
pimcore.elementservice.editElementKey(options);
}.bind(this)
});
//This code is for save&publish buttons
if (this.isAllowed("save")) {
buttons.push(this.toolbarButtons.save);
}
if (this.isAllowed("publish")) {
buttons.push(this.toolbarButtons.publish);
}
if (this.isAllowed("unpublish") && !this.data.general.o_locked) {
buttons.push(this.toolbarButtons.unpublish);
}
buttons.push("-");
if(this.isAllowed("delete") && !this.data.general.o_locked) {
buttons.push(this.toolbarButtons.remove);
}
if(this.isAllowed("rename") && !this.data.general.o_locked) {
buttons.push(this.toolbarButtons.rename);
}
var reloadConfig = {
xtype: "splitbutton",
tooltip: t('reload'),
iconCls: "pimcore_icon_reload",
scale: "medium",
handler: this.reload.bind(this, this.data.currentLayoutId)
};
if (this.data["validLayouts"] && this.data.validLayouts.length > 1) {
var menu = [];
for (var i = 0; i < this.data.validLayouts.length; i++) {
var menuLabel = ts(this.data.validLayouts[i].name);
if (Number(this.data.currentLayoutId) == this.data.validLayouts[i].id) {
menuLabel = "<b>" + menuLabel + "</b>";
}
menu.push({
text: menuLabel,
iconCls: "pimcore_icon_reload",
handler: this.reload.bind(this, this.data.validLayouts[i].id)
});
}
reloadConfig.menu = menu;
}
buttons.push(reloadConfig);
if (pimcore.elementservice.showLocateInTreeButton("object")) {
if (this.data.general.o_type != "variant" || this.data.general.showVariants) {
buttons.push({
tooltip: t('show_in_tree'),
iconCls: "pimcore_icon_show_in_tree",
scale: "medium",
handler: this.selectInTree.bind(this, this.data.general.o_type)
});
}
}
buttons.push({
tooltip: t("show_metainfo"),
iconCls: "pimcore_icon_info",
scale: "medium",
handler: this.showMetaInfo.bind(this)
});
buttons.push("-");
buttons.push({
xtype: 'tbtext',
text: t("id") + " " + this.data.general.o_id,
scale: "medium"
});
buttons.push("-");
buttons.push({
xtype: 'tbtext',
text: ts(this.data.general.o_className),
scale: "medium"
});
// version notification
this.newerVersionNotification = new Ext.Toolbar.TextItem({
xtype: 'tbtext',
text: ' <img src="/pimcore/static6/img/flat-color-icons/medium_priority.svg" style="height: 16px;" align="absbottom" /> '
+ t("this_is_a_newer_not_published_version"),
scale: "medium",
hidden: true
});
buttons.push(this.newerVersionNotification);
//workflow management
pimcore.elementservice.integrateWorkflowManagement('object', this.id, this, buttons);
// check for newer version than the published
if (this.data.versions.length > 0) {
if (this.data.general.o_modificationDate < this.data.versions[0].date) {
this.newerVersionNotification.show();
}
}
this.toolbar = new Ext.Toolbar({
id: "object_toolbar_" + this.id,
region: "north",
border: false,
cls: "main-toolbar",
items: buttons,
overflowHandler: 'scroller'
});
this.toolbar.on("afterrender", function () {
window.setTimeout(function () {
if (!this.data.general.o_published) {
this.toolbarButtons.unpublish.hide();
} else if (this.isAllowed("publish")) {
this.toolbarButtons.save.hide();
}
}.bind(this), 500);
}.bind(this));
}
return this.toolbar;
}
});
You have to do the same with tree.js:
pimcore.object.tree = Class.create({
onTreeNodeContextmenu: function (tree, record, item, index, e, eOpts ) {
e.stopEvent();
tree.select();
var menu = new Ext.menu.Menu();
var perspectiveCfg = this.perspectiveCfg;
var object_types = pimcore.globalmanager.get("object_types_store_create");
var objectMenu = {
objects: [],
importer: [],
ref: this
};
var groups = {
importer: {},
objects: {}
};
var tmpMenuEntry;
var tmpMenuEntryImport;
var $this = this;
object_types.each(function (classRecord) {
if ($this.config.allowedClasses && !in_array(classRecord.get("id"), $this.config.allowedClasses)) {
return;
}
tmpMenuEntry = {
text: classRecord.get("translatedText"),
iconCls: "pimcore_icon_object pimcore_icon_overlay_add",
handler: $this.addObject.bind($this, classRecord.get("id"), classRecord.get("text"), tree, record)
};
// add special icon
if (classRecord.get("icon") != "/pimcore/static6/img/flat-color-icons/timeline.svg") {
tmpMenuEntry.icon = classRecord.get("icon");
tmpMenuEntry.iconCls = "";
}
tmpMenuEntryImport = {
text: classRecord.get("translatedText"),
iconCls: "pimcore_icon_object pimcore_icon_overlay_add",
handler: $this.importObjects.bind($this, classRecord.get("id"), classRecord.get("text"), tree, record)
};
// add special icon
if (classRecord.get("icon") != "/pimcore/static6/img/flat-color-icons/timeline.svg") {
tmpMenuEntryImport.icon = classRecord.get("icon");
tmpMenuEntryImport.iconCls = "";
}
// check if the class is within a group
if(classRecord.get("group")) {
if(!groups["objects"][classRecord.get("group")]) {
groups["objects"][classRecord.get("group")] = {
text: classRecord.get("group"),
iconCls: "pimcore_icon_folder",
hideOnClick: false,
menu: {
items: []
}
};
groups["importer"][classRecord.get("group")] = {
text: classRecord.get("group"),
iconCls: "pimcore_icon_folder",
hideOnClick: false,
menu: {
items: []
}
};
objectMenu["objects"].push(groups["objects"][classRecord.get("group")]);
objectMenu["importer"].push(groups["importer"][classRecord.get("group")]);
}
groups["objects"][classRecord.get("group")]["menu"]["items"].push(tmpMenuEntry);
groups["importer"][classRecord.get("group")]["menu"]["items"].push(tmpMenuEntryImport);
} else {
objectMenu["objects"].push(tmpMenuEntry);
objectMenu["importer"].push(tmpMenuEntryImport);
}
});
var isVariant = record.data.type == "variant";
if (record.data.permissions.create) {
if (!isVariant) {
if (perspectiveCfg.inTreeContextMenu("object.add")) {
menu.add(new Ext.menu.Item({
text: t('add_object'),
iconCls: "pimcore_icon_object pimcore_icon_overlay_add",
hideOnClick: false,
menu: objectMenu.objects
}));
}
}
if (record.data.allowVariants && perspectiveCfg.inTreeContextMenu("object.add")) {
menu.add(new Ext.menu.Item({
text: t("add_variant"),
iconCls: "pimcore_icon_variant",
handler: this.createVariant.bind(this, tree, record)
}));
}
if (!isVariant) {
if (perspectiveCfg.inTreeContextMenu("object.addFolder")) {
menu.add(new Ext.menu.Item({
text: t('add_folder'),
iconCls: "pimcore_icon_folder pimcore_icon_overlay_add",
handler: this.addFolder.bind(this, tree, record)
}));
}
if (perspectiveCfg.inTreeContextMenu("object.importCsv")) {
menu.add({
text: t('import_csv'),
hideOnClick: false,
iconCls: "pimcore_icon_object pimcore_icon_overlay_upload",
menu: objectMenu.importer
});
}
menu.add("-");
//paste
var pasteMenu = [];
if (perspectiveCfg.inTreeContextMenu("object.paste")) {
if (pimcore.cachedObjectId && record.data.permissions.create) {
pasteMenu.push({
text: t("paste_recursive_as_childs"),
iconCls: "pimcore_icon_paste",
handler: this.pasteInfo.bind(this, tree, record, "recursive")
});
pasteMenu.push({
text: t("paste_recursive_updating_references"),
iconCls: "pimcore_icon_paste",
handler: this.pasteInfo.bind(this, tree, record, "recursive-update-references")
});
pasteMenu.push({
text: t("paste_as_child"),
iconCls: "pimcore_icon_paste",
handler: this.pasteInfo.bind(this, tree, record, "child")
});
if (record.data.type != "folder") {
pasteMenu.push({
text: t("paste_contents"),
iconCls: "pimcore_icon_paste",
handler: this.pasteInfo.bind(this, tree, record, "replace")
});
}
}
}
if (!isVariant) {
if (pimcore.cutObject && record.data.permissions.create) {
pasteMenu.push({
text: t("paste_cut_element"),
iconCls: "pimcore_icon_paste",
handler: function () {
this.pasteCutObject(pimcore.cutObject,
pimcore.cutObjectParentNode, record, this.tree);
pimcore.cutObjectParentNode = null;
pimcore.cutObject = null;
}.bind(this)
});
}
if (pasteMenu.length > 0) {
menu.add(new Ext.menu.Item({
text: t('paste'),
iconCls: "pimcore_icon_paste",
hideOnClick: false,
menu: pasteMenu
}));
}
}
}
}
if (!isVariant) {
if (record.data.id != 1 && record.data.permissions.view && perspectiveCfg.inTreeContextMenu("object.copy")) {
menu.add(new Ext.menu.Item({
text: t('copy'),
iconCls: "pimcore_icon_copy",
handler: this.copy.bind(this, tree, record)
}));
}
//cut
if (record.data.id != 1 && !record.data.locked && record.data.permissions.rename && perspectiveCfg.inTreeContextMenu("object.cut")) {
menu.add(new Ext.menu.Item({
text: t('cut'),
iconCls: "pimcore_icon_cut",
handler: this.cut.bind(this, tree, record)
}));
}
}
//publish
if (record.data.type != "folder" && !record.data.locked) {
if (record.data.published && record.data.permissions.unpublish && perspectiveCfg.inTreeContextMenu("object.unpublish")) {
menu.add(new Ext.menu.Item({
text: t('unpublish'),
iconCls: "pimcore_icon_unpublish",
handler: this.publishObject.bind(this, tree, record, 'unpublish')
}));
} else if (!record.data.published && record.data.permissions.publish && perspectiveCfg.inTreeContextMenu("object.publish")) {
menu.add(new Ext.menu.Item({
text: t('publish'),
iconCls: "pimcore_icon_publish",
handler: this.publishObject.bind(this, tree, record, 'publish')
}));
}
}
if (record.data.permissions["delete"] && record.data.id != 1 && !record.data.locked && perspectiveCfg.inTreeContextMenu("object.delete")) {
menu.add(new Ext.menu.Item({
text: t('delete'),
iconCls: "pimcore_icon_delete",
handler: this.remove.bind(this, tree, record)
}));
}
if (record.data.permissions.rename && record.data.id != 1 && !record.data.locked && perspectiveCfg.inTreeContextMenu("object.rename")) {
menu.add(new Ext.menu.Item({
text: t('rename'),
iconCls: "pimcore_icon_key pimcore_icon_overlay_go",
handler: this.editObjectKey.bind(this, tree, record)
}));
}
// advanced menu
var advancedMenuItems = [];
var user = pimcore.globalmanager.get("user");
if (record.data.permissions.create && perspectiveCfg.inTreeContextMenu("object.searchAndMove")) {
advancedMenuItems.push({
text: t('search_and_move'),
iconCls: "pimcore_icon_search pimcore_icon_overlay_go",
handler: this.searchAndMove.bind(this, tree, record)
});
}
if (record.data.id != 1 && user.admin) {
var lockMenu = [];
if (record.data.lockOwner && perspectiveCfg.inTreeContextMenu("object.unlock")) { // add unlock
lockMenu.push({
text: t('unlock'),
iconCls: "pimcore_icon_lock pimcore_icon_overlay_delete",
handler: function () {
pimcore.elementservice.lockElement({
elementType: "object",
id: record.data.id,
mode: "null"
});
}.bind(this)
});
} else {
if (perspectiveCfg.inTreeContextMenu("object.lock")) {
lockMenu.push({
text: t('lock'),
iconCls: "pimcore_icon_lock pimcore_icon_overlay_add",
handler: function () {
pimcore.elementservice.lockElement({
elementType: "object",
id: record.data.id,
mode: "self"
});
}.bind(this)
});
}
if (perspectiveCfg.inTreeContextMenu("object.lockAndPropagate")) {
lockMenu.push({
text: t('lock_and_propagate_to_childs'),
iconCls: "pimcore_icon_lock pimcore_icon_overlay_go",
handler: function () {
pimcore.elementservice.lockElement({
elementType: "object",
id: record.data.id,
mode: "propagate"
});
}.bind(this)
});
}
}
if(record.data.locked) {
// add unlock and propagate to children functionality
if (perspectiveCfg.inTreeContextMenu("object.unlockAndPropagate")) {
lockMenu.push({
text: t('unlock_and_propagate_to_children'),
iconCls: "pimcore_icon_lock pimcore_icon_overlay_delete",
handler: function () {
pimcore.elementservice.unlockElement({
elementType: "object",
id: record.data.id
});
}.bind(this)
});
}
}
if (lockMenu.length > 0) {
advancedMenuItems.push({
text: t('lock'),
iconCls: "pimcore_icon_lock",
hideOnClick: false,
menu: lockMenu
});
}
}
menu.add("-");
if(advancedMenuItems.length) {
menu.add({
text: t('advanced'),
iconCls: "pimcore_icon_more",
hideOnClick: false,
menu: advancedMenuItems
});
}
if (perspectiveCfg.inTreeContextMenu("object.reload")) {
menu.add({
text: t('refresh'),
iconCls: "pimcore_icon_reload",
handler: this.reloadNode.bind(this, tree, record)
});
}
pimcore.helpers.hideRedundantSeparators(menu);
pimcore.plugin.broker.fireEvent("prepareObjectTreeContextMenu", menu, this, record);
menu.showAt(e.pageX+1, e.pageY+1);
},
});

Not Getting Search value in Sencha Touch using searchfield

I want to display predictive text in search field, value for predictive text which comes from server. Here is my code so far:
View:
Ext.define('MyApp.view.AutoSearch', {
extend: 'Ext.dataview.List',
alias : 'widget.mainPanel',
config: {
store : 'AutoSearchStore',
itemTpl: '<div class="myWord">'+
'<div>Word is --<b>{name}</b>--- after search!!!</div>' +
'</div>',
emptyText: '<div class="myWord">No Matching Words</div>',
items: [
{
xtype: 'toolbar',
docked: 'top',
items: [
{
xtype: 'searchfield',
placeHolder: 'Search...',
itemId: 'searchBox'
}
]
}
]
}
});
Store:
Ext.define('MyApp.store.AutoSearchStore',{
extend: 'Ext.data.Store',
config:
{
model: 'MyApp.model.AutoSearchModel',
autoLoad:true,
id:'Contacts',
proxy:
{
type: 'ajax',
url: 'http://alucio.com.np/trunk/dev/sillydic/admin/api/word/categories/SDSILLYTOKEN/650773253e7f157a93c53d47a866204dedc7c363',
reader:
{
rootProperty:''
}
}
}
});
Model:
Ext.define('MyApp.model.AutoSearchModel', {
extend: 'Ext.data.Model',
requires: ['MyApp.model.AutoSearchModelMenu'],
config: {
fields: [
{name:'data', mapping: 'data'},
{name: 'name'},
],
},
});
and
Ext.define('MyApp.model.AutoSearchModelMenu', {
extend: 'Ext.data.Model',
config: {
fields: [
'name',
],
belongsTo: "MyApp.model.AutoSearchModel"
}
});
Controller:
Ext.define('MyApp.controller.SearchAutoComplete', {
extend : 'Ext.app.Controller',
config: {
profile: Ext.os.deviceType.toLowerCase(),
stores : ['MyApp.store.AutoSearchStore'],
models : ['MyApp.model.AutoSearchModel'],
refs: {
myContainer: 'mainPanel'
},
control: {
'mainPanel': {
activate: 'onActivate'
},
'mainPanel searchfield[itemId=searchBox]' : {
clearicontap : 'onClearSearch',
keyup: 'onSearchKeyUp'
}
}
},
onActivate: function() {
console.log('Main container is active--Search');
},
onSearchKeyUp: function(searchField) {
queryString = searchField.getValue();
console.log(this,'Please search by: ' + queryString);
var store = Ext.getStore('AutoSearchStore');
store.clearFilter();
if(queryString){
var thisRegEx = new RegExp(queryString, "i");
store.filterBy(function(record) {
if (thisRegEx.test(record.get('name'))) {
return true;
};
return false;
});
}
},
onClearSearch: function() {
console.log('Clear icon is tapped');
var store = Ext.getStore('AutoSearchStore');
store.clearFilter();
},
init: function() {
console.log('Controller initialized for SearchAutoComplete');
}
});
Json Data Looks Like:
"data":[
{
"name":"paint",
"author":"admin",
"word_id":"1",
"category":"Business",
"is_favourite":"yesStar"
},
{
"name":"abacus",
"author":"admin",
"word_id":"2",
"category":"Education",
"is_favourite":"yesStar"
},
{
"name":"abate",
"author":"admin",
"word_id":"3",
"category":"Education",
"is_favourite":"noStar"
},
{
"name":"testing adsf",
"author":"admin",
"word_id":"7",
"category":"Education",
"is_favourite":"noStar"
},
{
"name":"sprite",
"author":"admin",
"word_id":"6",
"category":"Business",
"is_favourite":"noStar"
},
{
"name":"newword",
"author":"admin",
"word_id":"8",
"category":"Architecture",
"is_favourite":"noStar"
}
]
})
If I type "A", then it displays No Matching Words, but I have words from "A" on json coming from server. How to solve this problem?
Any idea!
Code Sources Link
I don't know why you are using two models but just one thing you need to specify in AutoSearchStore :
reader:
{
rootProperty:'data'
}
instead of
reader:
{
rootProperty:''
}
to get the expected results in the list.
Hope this will be helpful :)

Resources