I have been trying to get a form in an Aukai dashlet to work for over a week now. It was realativly easy to get it to appear on the dashboard but nothing I have done has resulted in any this being sent to the server!
Has anyone or know of anyone that has a form fully working in a Dashlet?
Mine will not read from the OPtionsService (does not fill the dropdown of a select) nor post to any topic on submit, just sits there and does nothing. I can see the events in the debug window but on chrome and firefox debug view there is no network activity and server does nothing.
dashlet get js
model.jsonModel = {
rootNodeId: args.htmlid,
pubSubScope: instance.object.id,
bodyHeight: "400px",
services: [
{ name: "alfresco/services/LoggingService",
config: {
loggingPreferences:{
enabled: true,
all: true
}
}
},
"alfresco/services/OptionsService"
],
widgets: [
{
name: "alfresco/dashlets/Dashlet",
config: {
title: "My Messages",
bodyHeight: args.height || null,
componentId: instance.object.id,
widgetsForTitleBarActions: [
{
id: "MESSAGING_DASHLET_ACTIONS",
name: "alfresco/html/Label",
config: {
label: "Title-bar actions"
}
}
],
widgetsForToolbar: [
{
id: "MESSAGING_DASHLET_TOOLBAR",
name: "alfresco/html/Label",
config: {
label: "Toolbar"
}
}
],
widgetsForBody: [
{
id: "HELLO_DASHLET_VERTICAL_LAYOUT",
name: "alfresco/layout/VerticalWidgets",
config: {
widgetWidth: "350px",
widgets: [
{ name: "alfresco/forms/Form",
config: {
showOkButton: true,
okButtonLabel: "Send",
showCancelButton: false,
okButtonPublishTopic: "PUBLISH_TOPIC_MESSAGE",
okButtonPublishGlobal: true,
widgets: [{
name: "alfresco/forms/controls/TinyMCE",
config: {
fieldId: "MESSAGE_TEXT",
name: "message",
label: "Message",
widgetWidth: 200
}
},
{
name: "alfresco/forms/controls/Select",
config: {
fieldId: "RECIPENT",
name: "recipient",
label: "Send to",
optionsConfig:{
publishTopic: "ALF_GET_FORM_CONTROL_OPTIONS",
publishPayload: {
url: url.context + "/proxy/alfresco/api/people",
itemsAttribute: "people",
labelAttribute: "firstName",
valueAttribute: "userName"
}
}
}
}]
}
}
]
}
},
{
name: "alfresco/logging/DebugLog",
}
]
}
}
]
};
dashlet get html ftl
<#markup id="widgets">
<#processJsonModel group="share-dashlets" rootModule="alfresco/core/Page"/>
</#>
<#markup id="html">
<div id="${args.htmlid?html}"></div>
</#>
dashlet get desc xml
<webscript>
<shortname>Dashlet</shortname>
<description>An Aikau dashlet</description>
<family>dashlet</family>
<url>/dashlets/messaging</url>
</webscript>
I slightly modified your code to fetch the users and displaying ina dropdown.
Let me try with Option Service and will update you.
Created a new function getUserList and called /api/people to get the data and displayed in the dropdown.
Hope this helps you now.
model.jsonModel = {
rootNodeId: args.htmlid,
pubSubScope: instance.object.id,
bodyHeight: "400px",
services: [
{ name: "alfresco/services/LoggingService",
config: {
loggingPreferences:{
enabled: false,
all: true
}
}
},
"alfresco/services/OptionsService"
],
widgets: [
{
name: "alfresco/dashlets/Dashlet",
config: {
title: "My Messages",
bodyHeight: args.height || null,
componentId: instance.object.id,
widgetsForTitleBarActions: [
{
id: "MESSAGING_DASHLET_ACTIONS",
name: "alfresco/html/Label",
config: {
label: "Title-bar actions"
}
}
],
widgetsForToolbar: [
{
id: "MESSAGING_DASHLET_TOOLBAR",
name: "alfresco/html/Label",
config: {
label: "Toolbar"
}
}
],
widgetsForBody: [
{
id: "HELLO_DASHLET_VERTICAL_LAYOUT",
name: "alfresco/layout/VerticalWidgets",
config: {
widgetWidth: "350px",
widgets: [
{ name: "alfresco/forms/Form",
config: {
showOkButton: true,
okButtonLabel: "Send",
showCancelButton: false,
okButtonPublishTopic: "PUBLISH_TOPIC_MESSAGE",
okButtonPublishGlobal: true,
widgets: [{
name: "alfresco/forms/controls/TinyMCE",
config: {
fieldId: "MESSAGE_TEXT",
name: "message",
label: "Message",
widgetWidth: 200
}
},
{
name: "alfresco/forms/controls/Select",
config: {
fieldId: "RECIPENT",
name: "recipient",
label: "Send to",
optionsConfig: {
fixed: getUsersList()
},
requirementConfig: {
initialValue: true
}
}
}
]
}
}
]
}
},
{
name: "alfresco/logging/DebugLog",
}
]
}
}
]
};
function getUsersList() {
try {
var result = remote.call("/api/people?sortBy=fullName&dir=asc");
var userList = [];
if (result.status == status.STATUS_OK) {
var rawData = JSON.parse(result);
if (rawData && rawData.people) {
var dummyPerson = {
label: "Select Recipient",
value: " ",
selected: true
};
userList.push(dummyPerson);
for (var x = 0; x < rawData.people.length; x++) {
var item = rawData.people[x];
if (item.firstName != null && item.firstName != "" && item.userName.indexOf("#") == -1 && item.enabled == true) {
var displayName = item.firstName + " " + item.lastName;
var person = {
label: displayName,
value: item.userName
};
userList.push(person);
}
}
}
} else {
throw new Error("Unable to fetch User List " + result.status);
}
return userList;
} catch(err) {
throw new Error(err);
}
}
Related
We want to customize the faceted search by passing extra argument in the faceted search URL and read it in org\alfresco\slingshot\search\search.get.js---->search.lib.js.
http://localhost:8080/share/page/dp/ws/faceted-search#searchTerm=Koala.jpg&scope=repo&nodeRef=test
In searchDocLib json ,we have nodeRef value assigned it to selectedContainer but that argument is not coming in search.get.js. Basically how to pass extra argument in searchDocLib?How to enable logs for faceted-search.get.js so that logger statements should be printed in share.log?
var noderef = (page.url.args["nodeRef"] != null) ? page.url.args["nodeRef"] : "";
logger.log(page.url.templateArgs.nodeRef+"....nodeRef = "+nodeRef);
// Build the searchDocLib model
var searchDocLib = {
id: "FCTSRCH_SEARCH_RESULTS_LIST",
name: "alfresco/documentlibrary/AlfSearchList",
config: {
viewPreferenceProperty: "org.alfresco.share.searchList.viewRendererName",
view: viewRendererName,
waitForPageWidgets: true,
useHash: true,
useLocalStorageHashFallback: true,
hashVarsForUpdate: [
"searchTerm",
"facetFilters",
"sortField",
"sortAscending",
"query",
"scope",
"selectedContainer"
],
selectedScope: "repo",
useInfiniteScroll: true,
siteId: null,
rootNode: repoRootNode,
repo: false,
selectedContainer: noderef,
additionalControlsTarget: "FCTSRCH_RESULTS_MENU_BAR",
additionalViewControlVisibilityConfig: hideOnZeroResultsConfig,
widgets: [
{
id: "FCTSRCH_SEARCH_ADVICE_NO_RESULTS",
name: "alfresco/documentlibrary/views/AlfSearchListView",
config: {
widgetsForNoDataDisplay: widgetsForNoDataDisplay,
a11yCaption: msg.get("faceted-search.results.caption"),
a11yCaptionClass: "hiddenAccessible",
widgetsForHeader: [
{
id: "FCTSRCH_THUMBNAIL_HEADER_CELL",
name: "alfresco/documentlibrary/views/layouts/HeaderCell",
config: {
label: msg.get("faceted-search.results.heading.thumbnail"),
class: "hiddenAccessible",
a11yScope: "col"
}
},
{
id: "FCTSRCH_DETAILS_HEADER_CELL",
name: "alfresco/documentlibrary/views/layouts/HeaderCell",
config: {
label: msg.get("faceted-search.results.heading.details"),
class: "hiddenAccessible",
a11yScope: "col"
}
},
{
id: "FCTSRCH_ACTIONS_HEADER_CELL",
name: "alfresco/documentlibrary/views/layouts/HeaderCell",
config: {
label: msg.get("faceted-search.results.heading.actions"),
class: "hiddenAccessible",
a11yScope: "col"
}
}
],
widgets: [
{
id: "FCTSRCH_SEARCH_RESULT",
name: "alfresco/search/AlfSearchResult",
config: {
enableContextMenu: false
}
}
]
}
},
{
id: "FCTSRCH_GALLERY_VIEW",
name: "alfresco/documentlibrary/views/AlfGalleryView",
config: {
showNextLink: true,
nextLinkLabel: msg.get("faceted-search.show-more-results.label"),
widgetsForNoDataDisplay: widgetsForNoDataDisplay,
widgets: [
{
id: "FCTSRCH_GALLERY_VIEW_THUMBNAIL_DOC_OR_FOLDER",
name: "alfresco/search/SearchGalleryThumbnail",
config: {
widgetsForSelectBar: [
{
id: "FCTSRCH_GALLERY_VIEW_MORE_INFO_OR_FOLDER",
name: "alfresco/renderers/MoreInfo",
align: "right",
config: {
filterActions: true,
xhrRequired: true
}
}
],
publishTopic: "ALF_NAVIGATE_TO_PAGE",
renderFilter: [
{
property: "type",
values: ["document","folder"],
negate: false
}
]
}
},
{
id: "FCTSRCH_GALLERY_VIEW_THUMBNAIL_OTHER",
name: "alfresco/search/SearchGalleryThumbnail",
config: {
widgetsForSelectBar: [
{
id: "FCTSRCH_GALLERY_VIEW_MORE_INFO_OTHER",
name: "alfresco/renderers/MoreInfo",
align: "right",
config: {
filterActions: true,
allowedActionsString: "[\"document-delete\"]",
xhrRequired: true
}
}
],
publishTopic: "ALF_NAVIGATE_TO_PAGE",
renderFilter: [
{
property: "type",
values: ["document","folder"],
negate: true
}
]
}
}
]
}
},
{
id: "FCTSRCH_INFINITE_SCROLL",
name: "alfresco/documentlibrary/AlfDocumentListInfiniteScroll"
}
]
}
};
I've written a blog post that covers customizing the search page. Although it isn't exactly the same use case, the principle remains the same - you're going to want to create your own SearchService (extending the default one) and then swap yours for the default one in the faceted-search page model. You'll want to extend the onSearchRequest function to include the extra request parameter.
I have a Meteor application with a Mongo database containing documents with the following structure:
_id: "1234567890",
blocks: [{
type: "block",
block_id: "foobar",
items: [
{
type: "sub",
sub_id: "111",
items: [
{
type: "question",
question_id: "aaa"
},
{
type: "question",
question_id: "bbb"
}
]
},
{
type: "question",
question_id: "aaa"
}
]
}]
I want to be able to find all the questions with a question_id of 'aaa'. So far I have tried these queries, but am struggling to return any results:
questions = MyColl.find({
$or: [{
blocks: {
items: {
$elemMatch: {question_id: 'aaa'}
}
}
},{
blocks: {
items: {
type: "sub",
items: {
question_id: 'aaa'
}
}
}
}]
}).count();
Any ideas?
This is how I mananged it:
questions = MyColl.find({
$or: [{
'blocks.items': {
$elemMatch: {question_id: 'aaa'}
}
},{
'blocks.items.items': {
$elemMatch: {question_id: 'aaa'}
}
}]
}).count();
After I edit in the detal grid, the detail grid will unexpand.
I want it keep expand.
Thank you.
The following is my grid code:
$("#grid").kendoGrid({
editable:true,
columns: [
{ field: "name" },
{ field: "address" }
],
dataSource: [
{
name: "Beverages",
address: "street 1",
products: [
{ name: "Tea", price: 20 },
{ name: "Coffee", price: 23 }
]
},
{
name: "Food",
address: "street 2",
products: [
{ name: "Ham", price: 32 },
{ name: "Bread", price:34 }
]
}
],
detailInit: function (e) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: e.data.products,
editable:true,
});
}
});
The grid will collapse (unexpand) because it re-binds itself whenever a data item is updated. You will have to prevent the databinding.
detailInit: function (e) {
var grid = this;
$("<div/>").appendTo(e.detailCell).kendoGrid({
dataSource: e.data.products,
editable:true,
save: function() {
// Prevent the next data-binding
grid.one("dataBinding", function(e) {
e.preventDefault();
});
}
});
}
Here is a complete sample: http://dojo.telerik.com/uWuyI
Ext.define('MyApp.model.Facility', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.proxy.Ajax'
],
config: {
fields: [
{
name: 'FacilityId'
},
{
name: 'FacilityName'
}
]
}
});
Ext.define('MyApp.store.FacilityStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.Facility'
],
config: {
autoLoad: true,
model: 'MyApp.model.Facility',
storeId: 'FacilityStore',
proxy: {
type: 'ajax',
batchActions: false,
url: 'http://localhost/QuickFind/Services/EquipmentService.asmx/GetFacilities',
headers: {
'content-type': 'application/json'
},
reader: {
type: 'json',
rootProperty: 'd'
}
}
}
});
And trying the load the data into the list.
Ext.define('MyApp.view.facilityList', {
extend: 'Ext.dataview.List',
alias: 'widget.facilityList',
config: {
docked: 'top',
height: 200,
id: 'datalist',
ui: 'round',
scrollable: true,
store: 'FacilityStore',
onItemDisclosure: true,
itemTpl: [
'<div><p>{Facility.FacilityName}</p></div>'
]
}
});
and my controller launch i am binding the data to the list:
Ext.define('MyApp.controller.Facility', {
extend: 'Ext.app.Controller',
config: {
refs: {
dataList: '#dataList',
mainNav: 'mainNav'
}
},
launch: function() {
var me = this;
debugger;
Ext.getStore('FacilityStore').load();
var group_store = Ext.getStore("FacilityStore");
me.facilityList.setStore(group_store);
}
Store is loaded with records but it's not displaying in the list.
I hope u have solved ur problem by this moment,but still to answer the question u have posted..the problem is the itemtpl u have written..
ur's
itemTpl: [
'<div><p>{Facility.FacilityName}</p></div>'
]
The field u have mentioned is FacilityName so to get the record's from the store Facility
U just need to do this in ur itemtpl to get data in list:
itemTpl: [
'<div><p>{FacilityName}</p></div>'
]
I am new to ExtJs and I am using ExtJs4.
Now As shown in below image, There is one textfield named keywords, What I want to do is When I click on the button it will pass data of textfield to servlet and display resulted record in grid.
Now I have no idea how to do this. I am receiving JSON data response from servlet but don't know how to reload the store and refresh the grid.
Below is code for my store and grid.
Ext.define("Post", {
extend: 'Ext.data.Model',
proxy: {
type: 'ajax',
url: '/ezdi/searchServlet',
method: 'POST',
reader: {
type: 'json',
root: 'rows'
//,totalProperty: 'totalCount'
}
},
fields: [{
name: 'docid',
mapping: 'docid'
}, {
name: 'mrn',
mapping: 'mrn'
}, {
name: 'fname',
mapping: 'fname'
}]
});
var gridDataStore = Ext.create('Ext.data.Store', {
model: 'Post'
});
// Data store for grid end
Ext.define('Ezdi.Grid', {
extend: 'Ext.grid.GridPanel',
alias: 'widget.ezdigrid',
initComponent: function() {
var config = {
store: gridDataStore,
columns: [{
header: "DocID",
width: 100,
sortable: true,
dataIndex: 'docid'
}, {
header: "MRN",
width: 100,
sortable: true,
dataIndex: 'mrn'
}, {
header: "FirstName",
width: 100,
sortable: true,
dataIndex: 'fname'
}],
viewConfig: {
forceFit: false,
autoLoad: false
},
loadMask: true
};
}
});
You could use:
{
xtype: 'button',
text: 'Search',
handler: function() {
store.clearFilter(); //clear previous search value
var searchValue = Ext.getCmp("textFieldId").getValue(); //get new value
store.load().filter('jsonGridFielName', searchValue); //load filtered data
}
}
And for for multiple textfield search:
//FILTERS
var searchValue1 = Ext.getCmp("textFieldId1").getValue(); //value1
var searchValue2 = Ext.getCmp("textFieldId2").getValue(); //value2
var noValue = "0000xxxx"; //no Value, for empty field, use value that you are sure it is not going to be searched!!!
var clear = store.clearFilter(); //shortcut
if (!searchValue1 && !searchValue2) {
clear;
store.load().filter("jsonGridFielName1", noValue);
} else if (searchValue1) {
clear;
store.load().filter('jsonGridFielName1', searchValue1);
//...else if(searchValue n...)...
} else {
clear;
store.load().filter('jsonGridFielName2', searchValue2);
}
ezdigrid.js
// Data store for grid start
Ext.define("Post", {
extend: 'Ext.data.Model',
proxy: {
type: 'ajax',
url: '/ezdi/searchServlet',
method: 'GET',
reader: {
type: 'json',
root: 'rows'
//,totalProperty: 'totalCount'
}
},
fields: [{
name: 'docid',
mapping: 'docid'
}, {
name: 'mrn',
mapping: 'mrn'
}, {
name: 'fname',
mapping: 'fname'
}]
});
var gridDataStore = Ext.create('Ext.data.Store', {
// pageSize: 10,
model: 'Post'
});
// Data store for grid end
Ext.define('Ezdi.Grid', {
extend: 'Ext.grid.GridPanel',
alias: 'widget.ezdigrid',
initComponent: function() {
var config = {
store: gridDataStore,
columns: [{
//id:'ms',
header: "DocID",
width: 100,
sortable: true,
dataIndex: 'docid'
}, {
header: "MRN",
width: 100,
sortable: true,
dataIndex: 'mrn'
}, {
header: "FirstName",
width: 100,
sortable: true,
dataIndex: 'fname'
}],
viewConfig: {
forceFit: false,
autoLoad: false
},
loadMask: true
}; // eo config object
// apply config
Ext.apply(this, Ext.apply(this.initialConfig, config));
// call parent
Ezdi.Grid.superclass.initComponent.apply(this, arguments);
// load the store at the latest possible moment
this.on({
afterlayout: {
scope: this,
single: true,
fn: function() {
this.store.load({
params: {
start: 0,
limit: 30
}
});
}
}
});
} // eo function initComponent
});
demo.html
//handler for button click event
fbar: [{
xtype: 'button',
text: 'Search',
handler: function() {
var value = Ext.getCmp('_keyword').getValue(); //_keyword is textField
gridDataStore.load().filter('keywords', value);
}
}]
MyServlet
keyword = request.getParameter("keywords");
//code for quesry processing
Use extraParams in your model.
extraParams: {
keywords: 'your-value'
}
Put following code in your button click handler.
gridDataStore.proxy.extraParams.keywords = 'new value';
gridDataStore.load();