Custom action method not working in ng2 smarttable - angular5

I am trying to add custom action "Copy" in Ng2SmartTable Grid.
I am facing issue with click event handler of custom action. There are 3 buttons in grid Edit,Delete,Copy. Edit ,Delete is working fine. But 'Copy' method is not getting fired onclick of copy button.
Grid.component.html code
<ng2-smart-table [settings]="settings" (custom)="onCustom($event)" [source]="source" (edit)="onEdit($event)" (delete)="onDelete($event)"></ng2-smart-table>
OnEdit ,OnDelete working fine But OnCustom not working.
Grid.component.ts file code for settings for ng2smarttable.
mode: 'external',
actions: {
add: false,
custom: [{
name: 'copy', title: 'Copy'
}]
},
onCustom method not working at all.

There must be an issue with the function in your component, the code you have shared in your question is setup correctly and works in this stackblitz.
Please note: when the copy button is clicked the event is passed to the onCustom function in the app.component.ts and logs the event in the console.
https://stackblitz.com/edit/smarttable-e8gqql?embed=1&file=app/app.component.ts

Related

polymerfire/firebase-auth email verification not working

I am using firebase-auth (of polymerfire). Here is my element:
<firebase-auth id="auth" user="{{user}}"></firebase-auth>
I can observe changes on user when I login, so that part works fine. My problem is that for some reason I can't observe changes to user when I verify my email. Here are my observers:
properties: {
user: {
observer: '_obsUser'
}
},
observers: [
'_obsUser(user.*)'
],
I added the second observer just to make sure I observed all changes on the user. Again, no observer is triggered when I verify my email address. I even added a button to check the emailVerified property of user after I verified and it is still false.
Here is my check button I added:
<paper-button on-tap="_check">Check Verify</paper-button>
and the check function:
_check: function(){
console.log(this.user.emailVerified);
},
Even though the user has verified, _check still returns false.
If I reload my polymer app, the emailVerified prop will be true. But for some reason user that is bound is not updating properly without a hard reload.

Alfresco custom action permission

I have done a custom action. I can see the action in documentary library but i canot see it on faceted search result page.
<action id="custom-action" type="javascript" label="actions.custom.action">
<param name="function">onCustomActionlick</param>
</action>
So I went in the aikau-1.0.8.1.jar\META-INF\js\aikau\1.0.8.1\alfresco\renderers\_ActionsMixin.js file.
I see that we do a test to determine if action is allowed in this file :
if (this.filterActions === false || AlfArray.arrayContains(this.allowedActions, action.id))
On firebug i see that my costum action is not in the allowedActions object. My question is why ?
I think that actions wich have not permission are always allowed to all users. Am I right ?
What can i do to allow this action et make it visible on faceted search result page?
Thank you in advance.
You need to write an extension module which is described here: https://forums.alfresco.com/comment/159331#comment-159331.
In the JavaScript code you need to get the widget id of MERGED_ACTIONS and add your customAction to the array of allowdActions and define it in CustomActions.
This is the Aikau code from the link, probably it has been updated in the newer Alfresco version. So you need to extend this within your extension module.
You can probably just use org\alfresco\share\pages\faceted-search as your <sourcePackageRoot> in the module.
widgets: [{
id: "MERGED_ACTIONS",
name: "alfresco/renderers/Actions",
config: {
filterActions: true,
mergeActions: true,
allowedActions: ["folder-manage-rules", "folder-download", "folder-view-details", "CUSTOM3"],
customActions: [{
id: "CUSTOM3",
label: "Custom Action 3",
icon: "document-delete",
index: "10",
publishTopic: "DELETE_ACTION_TOPIC",
type: "javascript"
}],
widgetsForActions: [{
name: "alfresco/renderers/actions/ManageAspects"
}]
}
}]
The Document Library (at least up until Alfresco Share 5.1) is built with YUI, whereas the search page is built using Aikau. At the time of writing there is not yet parity of action handling between the search page and the Document Library, and the process of adding actions is very different.
In order to get your custom action to display in the faceted search page you'll need to do a couple of things:
Extend the search page to update the configuration for the "alfresco/search/AlfSearchResult" (it has the id "FCTSRCH_SEARCH_RESULT") to add your custom actions to the "additionalDocumentAndFolderActions" array (see http://dev.alfresco.com/resource/docs/aikau-jsdoc/AlfSearchResult.html)
Your custom action will publish a topic, so you need to create a new service to subscribe to that topic to perform the action. You will need to further extend the faceted search page so that your service is included on the page.
I'm paraphrasing from our latest blog the method we've used for this.
Our use case was we had existing actions in the document library view we didn't want to have to recreate, with standard configuration xml.
The first step is to create a Share Extension Module to add a Javascript controller in web-extensions/site-data/extensions/example.xml:
<extension>
<modules>
<module>
<id>Example Service</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.pages.faceted-search</targetPackageRoot>
<sourcePackageRoot>com.parashift.example</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
This will load some extra javascript, allowing you to adjust the widget config.
Create a file in web-extension/site-webscripts/com/parashift/example/faceted-search.get.js (or whatever package name you've used in sourcePackageRoot), add in a file called faceted-search.get.js with the following contents:
var searchResultPage = widgetUtils.findObject(model.jsonModel.widgets, "id", "FCTSRCH_SEARCH_RESULT");
if(searchResultPage != null) {
searchResultPage.config = {
enableContextMenu : false,
mergeActions : true,
additionalDocumentAndFolderActions : ["example-action"]
}
}
model.jsonModel.widgets.push({
id: "EXAMPLE_LISTENER",
name: "parashift/action/example"
});
This will:
Add example-action to the list of actions in the search results. This should already be a configured action in some share-config.xml file.
Add a new listener widget for you to listen to when the action button is clicked.
Add a file for your listener widget: META-INF/parashift/action/example.js
define(["dojo/_base/declare",
"dijit/_WidgetBase",
"alfresco/core/Core"
],
function(declare, _Widget, Core) {
return declare([_Widget, Core], {
postCreate: function () {
this.alfSubscribe("ALF_SINGLE_DOCUMENT_ACTION_REQUEST", lang.hitch(this, this._onPayloadReceive));
},
_onPayloadReceive: function (payload) {
if(payload.action.id == "example-action") {
this.alfLog("log", "Received action, handling accordingly");
.......
}
}
});
});
This code will listen for ALF_SINGLE_DOCUMENT_ACTION_REQUEST and execute the _onPayloadReceive function. In this function we filter to the example-action and execute any custom code.
The payload variable will include document and action objects. Using Debug Logging you can see what their shape is.
This is roughly equivalent to the old YUI method:
YAHOO.Bubbling.fire("registerAction", {
actionName: "onExampleAction",
fn: function(file) {
console.log("Received action, handling accordingly");
....
}
});

Hide paging toolbar for Tree Grid

Is the showPagingToolbar config option available for the rallytreegrid? This config option is listed for the rallygrid xtype but does not seem to work for the rallytreegrid.
It doesn't look like that config exists, you're right. You should be able to work around it by hiding it once the grid is rendered.
Simply add the following event listeners config to your existing config when creating your treegrid:
listeners: {
afterrender: function(treegrid) {
treegrid.down('#pagingToolbar').hide();
}
}

Registering Window Unload in extjs mvc

Do anyone have an idea about, how to register the window unload event in an ExtJS MVC application.
Ext.EventManager.on(window, 'beforeunload', function() {
alert('cross-exit tab click AND cross-exit browser click');});
The above code needs to be placed in a javascript file. I'm not sure which file should carry the above code.
window.onbeforeunload = function() {
return "You have made changes, are you sure you would like to navigate away from the page?";}.bind(this);
The above code does the job. I placed it under my main controller.
Put it in controller just inside init method:
init: function(){
Ext.EventManager.on(window, 'beforeunload', function() {
this.setAllValues(false);
});
this.control({
............
....

Sencha Touch error: 'myapp.mainpanel has no method setActiveItem'

Edit: Upon further examination I discovered that I hadn't included certain namespaces. Adding the relevant name spaces now gives the error:
'myapp.mainpanel has no method setActiveItem'
I am trying to build a sencha touch web app using the card layout mechanism. I make use of the following handler on a button on the landing page:
handler:function(){
myapp.mainpanel.setActiveItem(myapp.cards.vehicleSearchResults, { type: 'slide', cover: false, direction: 'left'})
}
But when I click on the button I get the error: Sencha Touch error: 'myapp.mainpanel has no method setActiveItem'
Does this mean myapp.cards.vehicleSearchResults is undefined?
I define it here:
myapp.cards.vehicleSearchResults = new Ext.Panel({
scroll:false,
layout:{
type:"vbox",
align:"stretch"
},
id: "vehicle-search-results-card",
dockedItems: [myapp.toolbars.searchResultsTitle, myapp.toolbars.searchResultsNav, myapp.toolbars.searchResultsCaption]
})
Any clues as to what I am doing wrong based on the above code?
The setActiveItem() method is only available if the panel has a card layout. Make sure you add the 'card' layout property in your panel definition.