DNN MVC module Missing Edit option - dotnetnuke

My dnn mvc module is missing the Edit option. Normally you will get the pencil icon for editing see pic below
I'm using Chris Hammond template for this MVC module that I'm working on.
This is my Module.dnn file look like
<moduleControls>
<moduleControl>
<controlKey />
<controlSrc>Abc.Controllers/Home/Index.mvc</controlSrc>
<supportsPartialRendering>False</supportsPartialRendering>
<controlTitle />
<controlType>View</controlType>
<iconFile />
<helpUrl />
<viewOrder>0</viewOrder>
</moduleControl>
<moduleControl>
<controlKey>Edit</controlKey>
<controlSrc>Abc.Controllers/Home/Edit.mvc</controlSrc>
<supportsPartialRendering>False</supportsPartialRendering>
<controlTitle>Edit Content</controlTitle>
<controlType>Edit</controlType>
<iconFile />
<helpUrl />
<viewOrder>0</viewOrder>
<supportsPopUps>False</supportsPopUps>
</moduleControl>
<moduleControl>
<controlKey>Settings</controlKey>
<controlSrc>Abc.Controllers/Settings/Settings.mvc</controlSrc>
<supportsPartialRendering>False</supportsPartialRendering>
<controlTitle>FishProNews Settings</controlTitle>
<controlType>Edit</controlType>
<iconFile />
<helpUrl />
<viewOrder>0</viewOrder>
</moduleControl>
</moduleControls>
</moduleDefinition>
I have a Home Controller that point to Index and Edit but since I'm missing the Edit (pencil icon) I'm not able to test the Edit function.
Does anyone know hot to get the Edit (pencil icon) option?

Jack,
The Edit icon is not a missing option. The pencil opens the ModuleAction menu that must be implemented by the module developer. Chris Hammond's template should have a decorator on your default module view's (Home) Index action.
[ModuleAction(ControlKey = "Edit", TitleKey = "AddItem")]
public ActionResult Index()
{
// Return the view and model
}
The ModuleAction decorator will add an item to the "pencil" module action menu. The ControlKey refers to the name of the action you want to call in your manifest file; ie: "Edit" which should have a Edit.cshtml and Edit action method in your Home controller. The TitleKey is the resource string for the menu. In your App_LocalResources/Home.resx you can add a resource string "AddItem.Text" with the value "Add New Item", for example.
You should see something like this:
To see a working example, refer to my RestaurantMenuMVC example project.

Related

Taskpane is not loading with page upon clicking on ribbon icon excel add in

I am using officeJS with react to create excel add-in. I have added ribbon tab with few ribbon buttons on it and on click on ribbon button I want to show specific pages on task pane. I created ribbon by taking reference from Excel-shared-runtime-scenario
PSB are my controls from manifest:
<CustomTab id="ShareTime">
<Group id="ServiceGroup">
<Label resid="ServiceGroup.Label"/>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<Control xsi:type="Button" id="BtnLoginService">
<Label resid="BtnLoginService.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="BtnLoginService.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="BtnLoginService.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
<Action xsi:type="ExecuteFunction">
<FunctionName>btnloginservice</FunctionName>
</Action>
</Control>
<Control xsi:type="Button" id="BtnLogoutService">
<Label resid="BtnLogoutService.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="BtnLogoutService.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="BtnLogoutService.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="SignOutButton.Icon"/>
<bt:Image size="32" resid="SignOutButton.Icon"/>
<bt:Image size="80" resid="SignOutButton.Icon"/>
</Icon>
<!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
<Action xsi:type="ExecuteFunction">
<FunctionName>btnlogoutservice</FunctionName>
</Action>
<Enabled>false</Enabled>
</Control>
<Control xsi:type="Button" id="BtnHomeService">
<Label resid="BtnHomeService.Label" />
<Supertip>
<!-- ToolTip title. resid must point to a ShortString resource. -->
<Title resid="BtnHomeService.Label" />
<!-- ToolTip description. resid must point to a LongString resource. -->
<Description resid="BtnHomeService.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16"/>
<bt:Image size="32" resid="Icon.32x32"/>
<bt:Image size="80" resid="Icon.80x80"/>
</Icon>
<!-- This is what happens when the command is triggered (E.g. click on the Ribbon). Supported actions are ExecuteFunction or ShowTaskpane. -->
<Action xsi:type="ExecuteFunction">
<FunctionName>btnhomeservice</FunctionName>
</Action>
<Enabled>false</Enabled>
</Control>
</Group>
Below is my command.js file contains the function which are available globally:
import {
SetRuntimeVisibleHelper,
updateRibbon,
signInFromRibbonO365,
signOutO365FromRibbon,
} from 'utils/excelUtils/office-apis-helpers';
import { createHashHistory } from 'history';
export function getGlobal() {
console.log('init globals for command buttons');
if (typeof window !== 'undefined') {
return window;
}
if (typeof global !== 'undefined') {
return global;
}
return undefined;
}
const g = getGlobal();
export function btnloginservice(event) {
const appHistory = createHashHistory();
SetRuntimeVisibleHelper(true);
// appHistory.replace('/login');
// appHistory.push('/login');
const port = window.location.port ? `:${window.location.port}` : '';
const root = `${window.location.protocol}//${window.location.hostname}${port}`;
console.log('path=', `${root}/#/login`);
window.location.href = `${root}/#/login`;
// signInFromRibbonO365();
event.completed();
}
export function btnlogoutservice(event) {
const appHistory = createHashHistory();
console.log('Open logout dialog');
// signOutO365FromRibbon();
appHistory.push('/logout');
event.completed();
}
export function btnhomeservice(event) {
const appHistory = createHashHistory();
SetRuntimeVisibleHelper(true);
// history.push('/');
appHistory.replace('/');
event.completed();
}
export function btnfeedbackservice(event) {
const appHistory = createHashHistory();
SetRuntimeVisibleHelper(true);
window.open(
'https://facebook.com',
'_blank',
);
appHistory.push('/feedback');
event.completed();
}
// the add-in command functions need to be available in global scope
g.btnloginservice = btnloginservice;
g.btnlogoutservice = btnlogoutservice;
g.btnhomeservice = btnhomeservice;
g.btnfeedbackservice = btnfeedbackservice;
This is working when I am running code locally using localhost on both online as well as desktop excel, enable/disable ribbon actions are also working correctly.
But when I am deploying application on azure cloud same code not working for desktop excel (office online excel working). Upon click of ribbon sign-in menu its not redirecting page into task pane. Its not redirecting to given path.
Please help to implement redirection from command function which get called on ribbon click. or suggest what would be the correct approach to implement that
Wants to redirect page on task pane on ribbon action.
Also its taking time upon clicking on ribbon menu first time to load and execute command function for that action, any idea how we can improve the performance of ribbon menu click
If you want to display any web page to the user as a result of the button click or some action, try using window.open('https://anysite.dom'). This should work if the domain is whitelisted in your manifest.

React-admin. How to show on separate page user activity

What I have.
I have few resources in my project -> users and user_activity.
Edpoint for getting user_activity looks like this:
curl base_url/rpc/user_activity?id=user_id -H "Content-Type: application/json" -X GET
Some React admin code
<Resource
name="user"
options={{ label: 'Users' }}
list={ UsersList }
create={ UsersCreate}
edit={ UsersEdit }
show={ UsersShow }
/>
<Resource name="user_activity"/>
What I need.
On the edit and show User page to put the button - "Activity", onclick on which I need to go to another page and show there table of User's Activity according to user_id.
I was thinking that for showing data from user_activity reasource I can use or new useQuery hook, but it should get somehow user_id as an argument, then how to pass it? Also was cheking as I understood it shows the data connected by the key from different resource but it show it at the same component and I need it to be on separate page.
How to do it?
What do you think is the best way to create a page and with what component inside in order to show the user_activity by user_id from another page?
Can you use a "ReferenceManyField" ?
I do something very similair using tabs instead of a new page.
For example:
<TabbedShowLayout>
<Tab label="activity" path="activity">
<ReferenceManyField
addLabel={false}
reference="activity"
target="user_id"
sort={{ field: 'Date', order: 'DESC' }}
>
<Datagrid>
<DateField source="Date" label="Date" showTime />
<TextField source="Type" label="Type" />
<TextField source="Result" label="Result" />
</Datagrid>
</ReferenceManyField>
</Tab>
</TabbedShowLayout>
Don't forget to add "activity" to your resources in
My dataprovider translate it to:
http://localhost:3001/activity?filter=%7B%22user_id%22%3A%XXXXX%22%7D&range=%5B0%2C24%5D&sort=%5B%22Date%22%2C%22DESC%22%5D

React-Admin: Clicking MenuItemLink for 2nd time clears form inputs

I have a react-admin based site working nicely.
Though i have an issue with the sidebar menu. If i click one of the items twice it clears all the form inputs. This is a link to an edit form of the resource item (in this case the current user profile):
<MenuItemLink to={"/users/" + user.id} primaryText="Profile" leftIcon={createElement(UserIcon)} onClick={onMenuTap}/>
with resource that looks like:
<Resource name="users" list={UserList} edit={UserEdit} create={UserCreate} icon={UserIcon} />
where UserEdit is
export const UserEdit = (props) => {
<Edit title={<UserEmail />} actions={<UserEditActions />} {...props}>
<SimpleForm validate={validateUserSave}>
<DisabledInput source="email"/>
<TextInput label="First Name" source="firstName" />
<TextInput label="Last Name" source="lastName" />
...
on first click all the inputs are populated from my REST api, but on 2nd tap (menu item selected) - all the form values are cleared...
Any ideas?
It is indeed a bug, I opened an issue on React Admin:
[#2291] Double-click on a Icon from the Menu reset the edition form
[#2322] Fix resetform when navigating to same page
A fix will be published with react-admin#2.3.2!
Thanks for reporting the issue.

Can't using ReferenceInput in admin-on-rest

Here is the ref : Admin-on-Rest
in app.js :
<Resource name="customers" list={CustomerList} icon={UserIcon} edit={CustomerEdit} create={CustomerCreate}/>
in customer.js :
<TextInput source="firstname" />
<ReferenceInput label="Partner" source="id" reference="partners" >
<AutocompleteInput optionText="name" />
</ReferenceInput>
<TextInput source="email" />
The problem is autocomplete not shown, but I check in log data retrieved from API end point /partners
And if I change reference to reference="customers", data and autocomplete shown.
Help please ??
You need another <Resource> for the relationship, even empty:
<Resource name="customers" list={CustomerList} icon={UserIcon} edit={CustomerEdit} create={CustomerCreate}/>
<Resource name="partners" />
It is well documented for <ReferenceField> (see the note), perhaps it needs the same note for <ReferenceInput>.
You <ReferenceInput reference="..."> needs to match the <Resource name="..."> for this to work. So this is the reason why reference="customers" worked for you.
If you want to get data from customers endpoints, but you want the label to be Partner you can specify it as label attribute on your ReferenceInput component, e.g. <ReferenceInput label="Partner" ...>.
The problem is probably the way you're importing your 'ReferenceInput' object. I had the same issue while creating my app and had no idea what is the problem.
Check your import line and if it looks like this:
import {ReferenceInput} from "../../src/mui/input/ReferenceInput";
then change it to look this way:
import ReferenceInput from '../../src/mui/input/ReferenceInput';
Hope that helps you!

How to know when a XAML element is finished loading

I have a custom control I'm developing that has a collection of items. When adding an item to the collection you're meant to do:
myCustomControl.BeginAddItems();
myCustomControl.Items.Add("a");
myCustomControl.Items.Add("b");
myCustomControl.Items.Add("c");
myCustomControl.EndAddItems();
If defining in XAML it would be:
<MyControl>
<Items>
<Item Name="a" />
<Item Name="b" />
<Item Name="c" />
</Items>
</MyControl>
How can I have EndAddItems (and ideally BeginAddItems) called when loading from XAML? Is there any way that MyControl can be notified by XAML that it has finished loading?
You can use the Loaded event

Resources