Joomla ACL custom actions - joomla2.5

I'm creating a custom (1.6) component wherein users can book a camp site. Users will be required to log in if they want to use funds/credits that they already have stored. Only certain groups can use these funds/credits.
I have created an access.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<access component="com_propbooker">
<section name="booking">
<action name="booking.create" title="Book Site" description="Allows users of this group to book sites." />
</section>
</access>
and my config.xml file:
<config>
<fieldset name="API Configuration" label="API Configuration">
<field name="google_api_key" label="Google API Key" type="text" size="50" default="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
</fieldset>
<fieldset name="Booking Permissions" label="Booking Permissions" description="Set Groups that can book sites">
<field name="booking_permission" label="Booking Permission" type="rules" class="inputbox" validate="rules" filter="rules" component="com_propbooker" section="booking" />
</fieldset>
</config>
It all shows up fine when I click the options button, but no changes are ever saved. It always flips back to "Inherited" when i click the "Save" button.
Thanks in advance for any insight.

Try using permissions as the fieldset name and rules as the fieldname in your config.xml.
Like this:
<fieldset name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC" >
<field name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
class="inputbox"
validate="rules"
filter="rules"
component="com_propbooker"
section="booking"
/>
</fieldset>
I would also consider using the section name component as it is the default naming. But your needs may be different.

Related

How to write jest test cases for navigation in react

I am new to Jest test cases writing, Trying to write the test case for checking navigation in an react application.
Currently I have written test case which works like below:
I have Login page which is having register link on it, which redirects user to the Register page. So what I am checking is
1. Loading the login page
2. Triggered Register link click event
3. So user moved to the Register page
but I am not able to check if the Register page is loaded or not? Is there any way to check the snapshot of the "Register" page and link in URL.
I have used jest, enzyme and react-test-render as shown in below code.
Login Page Html
<React.Fragment>
<BodyContainer noDrawer fullSpan>
<Grid container spacing={0} className={classes.gridContainer}>
<Grid item xs={12} md={6} lg={7} className="login--form">
<div className="login--form--container">
<img src={LogoPurple} alt="ABL" className="onboarding-logo" />
<h3>Welcome back! Please login to your account.</h3>
{error ? <p>{error}</p> : null}
<Field name="email" component={renderTextField} label="Email" style={styles.formField}/>
<Field name="password" component={renderTextField} label="Password" style={styles.formField} />
<Field name="rememberMe" component={renderCheckbox} label="Remember Me" />
<div className="has-spacing">
<Button variant="raised" size="large" color="primary" className="extraLarge" type="submit" onClick={this.handleSubmit}>
Login
</Button>
</div>
<Link to="forgot-password">Forgot Password</Link>
<p className="need-account">
Need an account?
<Link to="/register">
<strong> Sign up</strong>
</p>
</Link>
<LegalLinks />
</div>
</Grid>
</Grid>
</BodyContainer>
</React.Fragment>
In above code register is the link used to navigate.
thanks in advance...

Odoo hide "Create" and "Edit" buttons depend on state and role

I would like to hide "Create" and "Edit" buttons on state and group role in form view .For example hide Create and Edit buttons when the state is not draft and user belongs to request user group.
As I understand hide buttons I can on editing views. And on group role rules I can disable create or edit.
I tried to write a rule for request user group but then user can't use the button but see it.
From view I found only way to hide default Create and Edit buttons:
<form string="Request" create="false" edit="false">
But in that way I hide them for all users for all states. Is there another way how can I hide Create and Edit buttons depend on state and group role?
I tried to expand the base.xml template on conditions state is "approved" or "done" and the group role is purchase_request_user and view id is view_purchase_request_form "Create" and "Edit" button:
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space='preserve'>
<t t-extend="FormView.buttons">
<t t-if="widget.fields_view.state !== 'done' or widget.fields_view.state !== 'approved'">
<div class="o_form_buttons_view">
<button t-if="widget.is_action_enabled('edit')"
type="button"
class="oe_form_button_edit btn btn-default btn-sm" accesskey="E">
Edit
</button>
<button t-if="widget.is_action_enabled('create')"
type="button" class="oe_form_button_create btn btn-default btn-sm"
accesskey="C">
Create
</button>
</div>
</t>
</t>
</templates>
added 'base' to dependences.
UPDATED base.xml Now I can change "Create" button name depend on my view name but nothing that depends on my module states.
<templates>
<t t-extend="FormView.buttons">
<t t-jquery="button.oe_form_button_create" t-operation="replace">
<t t-if="widget.fields_view.name == 'purchase.request.form'">
<button t-if="widget.is_action_enabled('create')"
type="button" class="oe_form_button_create btn btn-default btn-sm"
accesskey="C">
New button name
</button>
</t>
</t>
</t>
</templates>
My form view xml peace:
<openerp>
<data>
<record model="ir.ui.view" id="view_purchase_request_form">
<field name="name">purchase.request.form</field>
<field name="model">purchase.request</field>
<field name="arch" type="xml">
<form string="Purchase Request" create="false" edit="false">
<header>
<button name="%(action_sale_order_reset)d" attrs="{'invisible': [('state','not in', ('to_approve_first'))]}" string="Reset" type="action" groups="purchase_request.group_purchase_request_manager"/>
<button name="button_to_approve_first" states="draft" string="Request approval" type="object" class="oe_highlight"/>
<button name="button_approved" states="to_approve_first" string="Approve" type="object" class="oe_highlight" groups="purchase_request.group_purchase_request_manager"/>
<button name="button_approvedd" states="approved" string="Return Request" type="object" class="oe_highlight" groups="purchase_request.group_purchase_request_manager"/>
<button name="button_create_order" states="approvedd" string="Create Order" type="object" class="oe_highlight" groups="purchase_request.group_purchase_request_user"/>
<button name="button_to_approve_second" states="create_order" string="Approve" type="object" class="oe_highlight" groups="purchase_request.group_purchase_request_manager"/>
<button name="button_approved2" states="to_approve_second" string="Done" type="object" class="oe_highlight" groups="purchase_request.group_purchase_request_manager"/>
<button name="button_rejected" states="draft,approvedd" string="Reject" type="object" groups="purchase_request.group_purchase_request_user"/>
<field name="state" widget="statusbar" statusbar_visible="draft,to_approve_first,approved,rejected" statusbar_colors="{"approved":"green"}"/>
</header>
<sheet>
<group>
<group>
<field name="date_start" readonly="1"/>
<field name="participate_process"/>
</group>
<group>
<field name="requested_by" readonly="1"/>
<field name="assigned_to" attrs="{'readonly': [('state','not in', ('draft'))]}" />
</group>
<notebook>
<page string="Order" attrs="{'invisible': [('state','in', ('draft', 'to_approve_first', 'approved', 'approvedd'))]}">
<field name="supply_ids" attrs="{'readonly': [('state','not in', ('to_approve_second'))]}"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
You have to write a template inheriting the 'FormView.buttons' one, check the context fields, like groups and state, and put a condition based on the wanted fields.
Something like this:
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space='preserve'>
<t t-extend="FormView.buttons">
<t t-if="widget.fields_view.state == <wanted_state>">
<your operations>
</t>
</t>
</templates>
Using this you can inspect all the FormView widget fields, you can find it in /odoo/addons/web/static/src/js/views/form_view.js.
I also found datarecord inside it, which should contain your state info and value.
Then, if you want to do the same with the buttons in edit mode, replace '.o_form_buttons_view' with '.o_form_buttons_edit'.
Tell me if you have problems. And again sorry for the delay, I was a little busy.
<t t-extend="FormView.buttons">
<t t-jquery=".o_form_buttons_view" t-operation="before">
<t t-log="widget"/>
</t>
</t>
Thank you! #Michele Zaccheddu using your answer I can get many types of the widget using
<t t-extend="FormView.buttons">
<t t-jquery=".o_form_buttons_view" t-operation="before">
<t t-log="widget"/>
</t>
</t>
Just put the code as a test and after update apps - go to form view, check using browser Developer Tools, In the console you will get the list from "Class", I'm using odoo 11 and can target
<t t-if="widget.initialState.data.state === 'draft'">
For other versions, please check the t-log yourself it can be different, but I haven't check for user group it may or may not be there...

Joomla Template Paramenter Type Menu Assignment

I use Joomla 3.2.1.
I create a new template and add some configuration parameter.
Now I need in my advanced configuration a selection, where I can set the menu assignment for a slideshow in my template. The Slideshow is html / javascript (jquery). I can enable/disable it in configuration.
But I want to assign it to menu item. Is there a configuration parameter type for this? I couldnt find.
my configuration looks like:
<config>
<fields name="params" >
<fieldset name="advanced">
<field type="spacer" label="Slideshow" />
<field name="isSlideshow" type="radio"
class="btn-group btn-group-yesno"
default="1"
label="Slideshow">
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<!-- add menu assingment-->
<field type="menut assignment???"....>
<field name="slide1" type="media" default=""
label="Slide 1"/>
<field name="slide2" type="media" default=""
label="Slide 2"/>
<field name="slide3" type="media" default=""
label="Slide 3"/>
</fieldset>
</fields>
</config>
You should create a module with the slideshow code.
Then assign the module to a position in your template, where you will include the position:
<jdoc:include type="modules" name="slideshow" />
Install the module in the slideshow position, then in the module settings, tab "Menu Assignment", choose "Only on the pages selected";
below you can tick the menu items you want it to show on.
There are a few cases where this is not sufficient, i.e. in the blog view the articles will share the same menu item, but you might want to treat them differently. You have many options here, the best is to create a different - named position in the template, and assign the modules to the appropriate one, i.e.:
<jdoc:include type="modules" name="slideshow-all" />
<jdoc:include type="modules" name="slideshow-articles" />

Field not displaying on list with Content types Inherits="False"

I've defined a content type 'related links' and set Inherits="False" and added line to remove out-of-the-box 'title' field as I don't want it showing in the view or new/edit/display forms, see (OPTION 1) in CAML below.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- ===== Fields ===== -->
<!-- Link Category -->
<Field DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Group="Custom"
Overwrite="True"
Type="Lookup"
ShowField="Title"
List="Lists/LinkCategoryList"
WebId="~sitecollection" />
<!-- ===== Content Type ===== -->
<!--
Related Links
- Parent ContentType: Item (0x01)
-->
<ContentType Name="Related Links"
ID="0x0100c11a1db14e564574bc49a2aa9bf325d3"
Group="Custom"
Description=""
Inherits="False"
Version="0">
<FieldRefs>
<!-- Title (OPTION 1) -->
<RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />
<!-- (OPTION 2)
<FieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}"
Hidden="TRUE" Required="FALSE" DisplayName="_hidden" />
-->
<!-- Link Category -->
<FieldRef DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Required="True" />
</FieldRefs>
</ContentType>
</Elements>
This does remove the 'title' field from the content type but when I try to associate the content type with a list it does not display the 'LinkCategory' field in the view or new/edit/display forms. Why is it so?
<?xml version="1.0" encoding="utf-8"?>
<List xmlns:ows="Microsoft SharePoint"
Title="Related Links"
FolderCreation="FALSE"
Direction="$Resources:Direction;"
Url="Lists/RelatedLinksListDefinition"
BaseType="0"
EnableContentTypes="True"
xmlns="http://schemas.microsoft.com/sharepoint/">
<MetaData>
<ContentTypes>
<!-- Related Links -->
<ContentTypeRef ID="0x0100c11a1db14e564574bc49a2aa9bf325d3" />
</ContentTypes>
<Fields>
</Fields>
<Views>
<View ...etc...>
<ViewFields>
<FieldRef Name="LinkCategory"></FieldRef>
</ViewFields>
<Query>
<OrderBy>
<FieldRef Name="ID"></FieldRef>
</OrderBy>
</Query>
</View>
</Views>
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx"
SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
</MetaData>
</List>
As a work around I've set Inherits="True" on the content type and used (OPTION 2) in content type CAML and that hides the 'title' field, but would really like to understand what's going on here and what's the best approach to take. Thanks in advance!
PS: This post has similar question: SharePoint 2010: RemoveFieldRef and Inherits="TRUE"
PSS: When I browse via SP Manager 2010 after deploying using OPTION 1, I get the following:
'Link Category' Field created correctly
'Related Links' Content Type created correctly with 'Link Category' field
'Related Links' list created with 'Related Links' Content Type associated
However 'Related Links' list has no reference to 'Link Category' Field.
Ok so was on my way up the garden path...
The issue why 'Link Category' Field was not being created on the 'Related Links' list wasn't related to setting Inherits="False", it was because I had not defined it in the list schema even though I'd defined it in the content type. As mentioned here:
http://msdn.microsoft.com/en-us/library/aa543576.aspx
When SharePoint Foundation creates a list instance, it includes only
those columns that are declared in the base type schema of the list or
in the list schema. If you reference a site content type in the list
schema, and that content type references site columns that are not
included in the base type schema of the list or in the list schema,
those columns are not included. You must declare those columns in the
list schema for SharePoint Foundation to include them on the list.
And here:
http://stefan-stanev-sharepoint-blog.blogspot.com/2010/03/contenttypebinding-vs-contenttyperef.html
One ugly thing about it is that you specify a site content type to be
attached to the list based on that list definition but the framework
doesn’t provision the fields in the content type if they are missing
in the list – so you need to add manually all content type’s fields in
the Fields element of the list schema file. This is actually what I
called the fields’ redefinition issue...
So duplicated Field element below from the content type definition to list schema:
<Fields>
<Field DisplayName="Link Category"
Name="LinkCategory"
ID="{654EAC00-342B-4176-9D91-613AD724F684}"
Group="Custom"
Overwrite="True"
Type="Lookup"
ShowField="Title"
List="Lists/LinkCategoryList"
WedId="~sitecollection" />
</Fields>
I can confirm that using Inherits="False" & <RemoveFieldRef ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" /> does remove the title field.
Here's another good link about Inherits="False" for those who stumble upon this post.
https://sharepoint.stackexchange.com/questions/2995/mysteries-of-the-contenttype-inherits-attribute

How to programmatically disable buttons or add/remove items from dropDown with Office Ribbon UI

I have written a simple C++ COM Office add-in that loads a ribbon XML definition and displays a simple ribbon tab. It features some buttons and a dropDown (combobox/droplist). I can handle button click events and combo selection change events like a charm.
Now I want to update ribbon UI according to changes in the active document so that some buttons are disabled and some items added/removed from combobox.
I have searched up and down and could not find a way to control this. Am I missing something very obvious? How can I change button enabled state from anywhere in my code?
The way I've seen it done, using the Windows Ribbon control: the extra buttons must be specified in the XML markup, at design time. At runtime, you call SetModes() to specify which sets of widgets gets displayed in the ribbon.
Like this:
<Application.Views>
<Ribbon>
<Ribbon.Tabs>
<Tab CommandName="cmdTabMain" ApplicationModes="0,1">
<Group CommandName="cmdGroupCommon"
SizeDefinition="ThreeButtons"
ApplicationModes="0,1">
<Button CommandName="cmdButtonNew" />
<Button CommandName="cmdButtonOpen" />
<Button CommandName="cmdButtonSave" />
</Group>
<Group CommandName="cmdGroupSimple"
SizeDefinition="TwoButtons"
ApplicationModes="0">
<Button CommandName="cmdButtonSwitchToAdvanced" />
<Button CommandName="cmdButtonDropA" />
</Group>
<Group CommandName="cmdGroupAdvanced"
SizeDefinition="FourButtons"
ApplicationModes="1">
<Button CommandName="cmdButtonSwitchToSimple" />
<Button CommandName="cmdButtonDropA" />
<Button CommandName="cmdButtonDropB" />
<Button CommandName="cmdButtonDropC" />
</Group>
</Tab>
</Ribbon.Tabs>
</Ribbon>
</Application.Views>
Then (in C# anyway) in the click handler, you do _ribbon.SetModes(1) or _ribbon.SetModes(0).