Sails.Js implement friendly url - sails.js

I'm new on sailjs. Do you know if it is possible to implement a friendly URL system ?
For exemple, if i want to manage products, how can i handle it in my controller by the formatted title instead of just id.
Thanks

Sailsjs has no built in support for this but the steps you have to take are pretty simple.
These formated strings in your urls are called slugs. A quick search on npm delivers several results.
The way to handle slugs with sails is to implement lifecycle callbacks (scroll down a bit to the section about the callbacks) on your product model.
Use the beforeCreate method and generate your slug into a property on your model. Inside beforeUpdate you should check if the data that you have slugged before has changed and create a new slug if needed.
Create a matching route. e.g /product/:slug
In your controller you just switch your where clause from the product id to the property you generated in your models beforeCreate method.
If the possibility exists that two products have the same name you should add the product id or other unique info to the slug.
happy coding. if something is unclear leave a comment

Related

formio: How to populate fields without custom javascript code?

I have searched for hours and tried several approaches. No luck.
Scenario:
There is a formio Resource Form for Doctors that includes the Doc's practice number, name, address, etc.
A new form is created for prescription medication. The form has a Select component to find the doctor's practice number. Once the correct doctor is selected, the fields showing the Doc's name, surname, address, etc., must be automatically populated.
I understand that anything is possible with custom code, but this is such a common requirement that I'm convinced it can be done with standard functionality.
Can you show me how to do this?
Thanks,
Alan
In the validation tab, do a custom validation.
Using the drop down's value, look up the doctor's information.
Then, use the following code as a guide to update your fields.
FormioUtils.searchComponents(form.components, {key:"address"})[0].setValue("PO Box 123");

Prefilled notes of Class attributes in Enterprise architect

is there a way to have prefilled attributes notes in enterprise architect?
It should be something like this scenario:
1) I create new attribute
2) Enterprise architect prefill note of attribute with predefined text
Something like template for attributes.
Thank you for any advice
I know this won't help directly this question.
Anyways you can achieve it through an external addin.
All you need to do is handle the EA_OnPreNewAttribute and EA_OnPostNewAttribute broadcast events .
This isn't quite what you're after but it is possible to create an Attribute stereotype in a Profile and add to this a Tag with an initial value set to what ever you want. When you create an attribute with this stereotype, this means your predefined text would appear in a tag-value for the attribute rather than the note. Not ideal, but might work for you.
You could also have a go at writing some JavaScript to do this as well (under Scripting in EA). You'd have to use the JS to navigate the repository structure, find the attributes in question, and update their note. I don't believe you can attach a script to a UI event, so I think you'd be stuck running this post-hoc rather than having the note auto-populate on attribute creation.

Acumatica Web API popup Note (Enter Record Note)

I saw that once the Document is Closed/canceled/hold, there is no way to change any data field but the "Notes". Then Document notes is the way to save some critical information we need to track about the document.
So I think to create a new Screen to manage the "Record notes" using the guid as parameter.
Before go any further, is there a simple way to update the Notes if I know the guid, without using the SO screen?
You can create a custom screen which displays the notes related to an object, in your case an SO. You will need a selector to select the order number, and then using said order number, you can link it to its notes. Here is an example view to get the note you will edit:
public PXSelectJoin<Note, InnerJoinSingleTable<SOOrder, On<SOOrder.noteID,
Equal<Note.noteID>>>, Where<SOOrder.orderNbr, Equal<Current<SOOrder.orderNbr>>>> SONote;

SYMFONY FORM - filter attribute form on top with submit button, that provides a table with other form used to edit each row details

I am looking for best practices on SYMFONY FORM handling to achieve the following standard page (surprisingly I haven't found anything similar existing yet on SO).
Here is a shema of what I want to achieve:
As you can see at the top there is a SYMFONY FORM to filter the results that should be displayed.
It displays a table and each tuple of the table should permit to open another SYMFONY FORM kind linked to the tuple.
I am in the process of learning SYMFONY FORM, so far, I can manage to create the top row FORM to set the filter that'll apply to the table display.
But I wonder if anyone has experience on the second part: Displaying the table that embed as well many forms of a similar kind -That seems a bit more complex. I read about TWIG.EXTENSION and FORM.COLLECTION, I'll investigate that. But if someone could save me to re-invent the wheel and lead me to some direct shortcut, I'd be really grateful.
No idea if it's the best practice, but one way to do it would be to create a new property for your entity being listed in this table, called $editionForm (without mapping it to the database) for example.
Then, either throught a custom loop or by listening to a doctrine (or any ORM you use) hydration event (or triggering such an event if you don't use any ORM), fill the property with the generated form, probably within a dedicated service.
Then, just use it in your template like this :
$entity->getEditionForm()->render()

How to add an autocomplete field in forms Symfony2?

Actually, I can assign a task to a user in the edition task. I display a dropdown list of all user in the system when I edit a task. Now, I would to be able to display a text input with autocomplete for user, and be able to add user if is not exist.
How to do that?
Thanks in advance.
Two things you need to do:
1) Create a Data Transformer
hich will let you use an input field instead of the default dropdown to the linked entity.
The Data Transformer basically transforms your input (in your case a username string) to actual user object that you can store with your entity. It will let you define an input field instead of the default dropdown to the linked entity. Have a look at the documentation, it's pretty straight forward.
2) Create the Ajax autocomplete
This can be done using any library you want (jQuery, Prototype etc.) on the client side, and server side you handle this in your Controller action and replies with either JSON or a rendered template. There are plenty of tutorials for this out there. The Ajax result could include a link to create a new user, if none is found.
The Data Transformer is what you need to focus on, and I would get that working before working on the UI.