Hide/show urls in form view in openerp - forms

I am trying to put a link to download docs files in form view. I already have the links and I made a custom web controller that actually does the download but the problem is that they present in every part of the view. I want it to appear based on specific condition where the state field of an applicant is set to a specific value similar to buttons in form view.
Bellow is an example of a button that appears based on the state condition:
<button name="action_open_agreement_form" type="object" string="P020 Declaration and undertaking" attrs="{'invisible':[('state','!=','done')]}"/>
this allows me to show a button if the state of the applicant is not done.
The link I have is as bellow in the xml
<record model="ir.ui.view" id="view_sefarer_applicant_form">
<field name="name">Jobs - Recruitment Form</field>
<field name="model">seafarer.applicant</field>
<field name="arch" type="xml">
<form string="Jobs - Recruitment Form" version="7.0">
...
<sheet>
......
<div class="oe_right oe_button_box">
....
P014 Drug/Alcohol Delcaration
.....
</div>
</sheet>
.....
I need to use something like attrs but it is not working, I also tried to use javascript with on window load or document ready but that's not working too. I also tried desperate things like having a button with attrs with the condition and having a onclick action on it that clicks the link and having the link hidden but that didn't work as well.
I am pretty desperate and any help would be appreciated.

You can make an entire div invisible based on group membership or field content (such as state), or you can put the links in fields, and make those invisible using the same criteria.

Related

How to change the group position of an Add-in inserted into a default office tab?

I have created an Office Add-In for Word, and the icon is placed into the Insert tab, but by default it is in the very last position on the ribbon. I want my group to be placed in the first position of the tab, before Pages (this appears to be the first group by default). Is there something I can add into the manifest XML file to place the group at the start of the tab?
My manifest file currently looks something like this:
...
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<OfficeTab id="TabInsert">
<Group id="MyCompany.MainGroup">
<Label resid="MyCompany.MainGroup.Label" />
<Icon>
...
</Icon>
<Control xsi:type="Button" id="MyCompany.ActionButton">
<Label resid="MyCompany.ActionButton.Label" />
...
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
...
I would imagine that if this is possible, there should be something I can add underneath the Group element, but I don't see anything relevant in the documentation. On the other hand, absence from the documentation doesn't mean it doesn't exist, since the Icon element is not listed there either, and without it my Add-In doesn't load.
The other element I can imagine a suitable option would exist is on the ExtensionPoint (documentation), but I don't see anything suitable there either.
This is not possible. The add-in buttons would always come after the default office ribbon controls. The only way where you can insert them at the beginning of the line would be to create a custom tab.

fluid template and TYPO3: Form inside a form - submit doesn't work anymore

If i insert a form inside a form, the submit button in the "outer" form doesn't work anymore.
Short code example:
<f:form action="update" name="examples" object="{examples}" >
<f:for each="{examples}" as="example"
<f:form.textfield property="name" value="" />
<f:form.checkbox property="checked" value="1" checked="0" /><br />
<f:form action="delete" name="example" object="{example}" >
<f:form.submit value="delete" />
</f:form>
<f:form.submit value="update" />
</f:form>
So basically (this is an extremely simplified version of my real life project) i want to be able to change the values of the textfield and checkbox which are then passed to the updateAction. The for each loop just generates multiple entries and therefore multiple forms just containing the delete button for that specific object so to speak. I can address these objects by __identity and they can be deleted by the button next to them, that's not the problem.
But the submit button for update doesn't work anymore if i put other forms with their respective submit buttons into this form.
Is there any solution for that?
Forms inside forms do not work (and is not proper HTML either).
Longer version that answers the question you didn't ask: to achieve your goal here, use f:link.action to create a link to the delete controller action with your {example} object as parameter. Then style that link to look like a button if you wish.
Completely unrelated from TYPO3 or Fluid you should know that nesting forms is not allowed.
However, at least the editing part of your code can be made valid with a single form:
<f:form action="update" name="examples" object="{examples}" >
<f:for each="{examples}" as="example" iteration="i">
<f:form.textfield property="{i}.name"/>
<f:form.checkbox property="{i}.checked" value="1"/>
</f:for>
<f:form.submit value="update"/>
</f:form>
With this set up it is not possible to also have a delete action in place since you'd need a submit button which does two things:
Request the delete action:
<f:form.button type="submit" name="action" value="delete">Delete</f:form.button>
Point at the entity to address:
<f:form.button type="submit" name="example" value="{example}">Do something with {example.title}</f:form.button>
You should add a separate view for editing single example objects instead. The current view then becomes a list with links to that edit view. In that view your form object becomes a single example which allows you to add two submit buttons for each action.

jQuery Toggle in SharePoint using XSLT, but all the instances toggle not just the clicked one

I am having a problem with my XSLT, I am using SharePoint 2010 and I am building a custom front-end that will pull data from lists and render the data in a nice manner. I have figured out how to use XSLT with HTML to render a SharePoint list, I wasn't able to add an image of my news feeds because my rep is too low but I will get it up!
Now here is where my problem starts:
I am using jQuery toggle to show/hide the body paragraph of this news feed. The Continue Reading button is where my issue is, every time I click on the "Continue Reading" button in the lower right of each news post, it show/hides all the news items, not just the one I click on.
I have tried using Bootstrap collapse and now I am using jQuery Toggle() however I run into the same issue! Take a look at my XSLT code snippet to display thee body paragraph and the corresponding jQuery code snippet that actives the show/hide toggle:
XSLT:
<tr class="spacer">
<td valign="top" class="td-newscontent">
<div class="news content">
<!-- start excerpt -->
<xsl:value-of select="#BodyExcerpt" disable-output-escaping="yes" />
<div class="moving">
<xsl:value-of select="#Body" disable-output-escaping="yes" />
</div>
<!-- end news excerpt -->
<!-- start continue reading link -->
<xsl:text disable-output-escaping="yes"><![CDATA[<br class="continue-br" />]]></xsl:text>
<a class="butt pull-right continue-right">Continue Reading</a><br /><br />
<!-- end continue reading link -->
</div>
</td>
</tr>
Javascript (jQuery)
$(".moving").hide();
$(".butt").click(function() {
$(".moving").toggle("slow", function() {
});
});
.moving is the actual #body being shown/hidden
.butt is the "continue reading" button (I know butt was a bad name to use)
I have read a few things on the net about "this" but I am not sure how to use it.
First time posting so I couldn't post any images, but when you click on "continue reading" all the body news articles expand then you click it again and all the body news items contract, what I would like it to do is open just the one I am clicking on!
I have a lot going on, everything is housed in SharePoint, using HTML5, Css3, jQuery and XSLT. I started by using IDs but I switched to classes, not sure if that was a good idea but it functions, but not as intended.
Any help would be appreciative, I have been researching this issue for almost 2 weeks so I finally decided to ask some experts :) (Feel free to ask any questions or ask for more information, I will answer with everything I got!)
You are close, so well done for getting this far! Your problem lies in your JavaScript. If you look at the rendered code using your browser's developer tools (F12), you will find that all of the different body texts have the same class (moving) and all of the buttons have the same JavaScript onclick, which is to toggle everything of class .moving.
Thus the solution you are looking for is to match each button with its respective body text. There are two main ways you can do this.
You can give each text div and each button a unique ID by assigning it to some unique feature of the list item (SharePoint list items already have a unique identifier as the field ID). Using xsl:value-of within HTML attributes would violate XML rules, so you can use something called an Attribute Value Template, which is the bit in the curly braces:
<div id="newstext_{#ID}">
<xsl:value-of select="#Body" disable-output-escaping="yes" />
</div>
<!-- etc... -->
<a onclick="$('#newstext_{#ID}').toggle('slow', function() {});">Continue reading</a>
Modify just the JavaScript to target the parent of the button. The following code selects the parent DOM element of the button, which should be the div of class .news, then finds the child of class .moving, then applying your toggle:
$(".butt").click(function() {
$(this).parent().find(".moving").toggle("slow", function() {
});
});
The second method is easier but can get complicated if you end up running a lot of JavaScript. It is easier (and more efficient) to select elements by ID, so personally I think the extra effort is worth it. I haven't tested this code so let me know if it doesn't work. On some of your other points:
no, butt is not a good name for a class - remember, you can use element types in your jQuery selectors, so there is no need to duplicate the type as the class. For example, $('a') selects all the anchor tags on the page.
IDs should be used when elements need to be uniquely identified (e.g. for scripts), classes when you are grouping elements together (e.g. for styles).

Blur for submitting form AngularJS

Hi I have a following html markup
<h2>First Name Last Name</h2>
<form>
<div>
<input name="fname">
<input name="lname">
</div>
</form>
You click on a header to show the form fields and to edit them (blur hides the fields and shows the header again).
I have a problem because the first and last name are in the same header, so you click on one item to edit two fields.
I am submitting the form on a blur event for the input fields but when I click the last name, because blur is being called in the first name, I cannot edit the second field.
I am using AngularJS which is also presenting a problem because I cannot figure out which element is focused because document.activeElement returns the entire body.
Any help is much appreciated!
Assuming you're using ngBlur directive on the input element, you can mix it with ngFocus to keep elements visible as wanted: <input name="fname" ng-focus="showFields=true;" ng-blur="blurField($event);" >
Using a function for ngBlur, you will have access to the $event object which in turn will expose the elements you need (like target or related). Afterwards, you can trigger form submit depending on your needs.
A demo plunker is HERE.

How to display everyone of the label and the radio choices in its own line?

I'm using Struts2. By default, when using the struts form, the label and the choices are displayed in the same line. How can I do to make the label in a line, and every radio choice in its own line? Is there a way by CSS? I need your help guys. Here it is how my form looks like. Thank you!
<s:form action="resultAction" namespace="/">
<s:radio label="Gender" name="yourGender" list="genders" value="defaultGenderValue" />
<s:submit value="submit" name="submit" />
</s:form>
Which theme are you using as by default struts2 use xHtml theme and which generate certain set of Tables to render the view.
Struts2 use free-marker template to render the HTML for tags and you can customize theme as per your choice or can create you rown theme.
Try with simple theme which will not generate any table or div and will render plain HTML for you are you have all way to apply your custom CSS to change/customize the view.
You can set the theme per page basis on for the whole application for per page basis add the following line in the head section
<s:set name="theme" value="'simple'" scope="page" />
for whole application you can either set in struts.properties file or in struts.xml file though the second one is more preferable.
<constant name="struts.ui.theme" value="simple" />
If you want to play with theme here is the link for same
struts-2-themes