Adding a custom property dependent on another in Umbraco - customization

The request
I want to add Members to their department in our Company, but our company has more offices and each office its own departments, so we need to organize that first and then try to assign each Member to its department so that they only have permissions to access their own department.
Departments overview as Umbraco Content:
Root Node
-Office 1
-- Department1.1
-- Department1.2
-Office 2
-- Department 2.1
-Office 3
-- Department 3.1
-- Department 3.2
-- Department 3.3
Now, if I add a User, I want one property to select the office and another to select the department.
Possible solutions
Checking here and there, I've seen I can make the Office property using the UltimatePicker type in Umbraco creating a custom data-type linked to a parent node and then a property inside my MemberType. That will display the offices under "Root Node" and link the member to one of them.
Now, to make the department property I've seen there could be some way using a custom manually-coded property, adding a usercontrol and using it to display the office children dynamically (I've not tried it yet, I'm theorizing).
But I am worried that the second property will be dependent on the first one, and when I've tried to create my custom property implementing umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor in my usercontrol it only allows me to save one value, not two of them. Which has sense as this is supposed to be A property, and not a bunch of them.
My question
Now, what's the best way to have those 2 custom properties and also make sure that in case I change the office the department will be also refreshed?
Best crazy idea at the moment
Up to this moment, I can only imagine creating 2 usercontrols, one for each property, and manually clean the department each time the office is updated, though I don't know if this is possible (Can I really get departments dynamically? Can I clean the dep. property FROM office property usercontrol?) and I would prefer to have them together as to simplify the codes.

If the relationship is key and you need to prevent a user from accidentally choosing a department that doesn't belong to an office, then you could create a single usercontrol that contains two drop-down menus. The first menu displays the offices and the second is only populated (preferably by an ajax call) once an office selection has been made.
The code for retrieving the offices and departments would be relatively straightforward using the umbraco api.
The usercontrol could then save the id's of each to xml or a comma delimited list.
Alternatively, you could just allow the user to select a department and the office is implied by the choice of department. You could use the uComponent's multi-nodepicker and filter the node selection to only the Department doc type. The overhead then is in the UI code where you have to work out the Office from the Department.
To get around this, you could have a label property that simply stores the ID of the Department's Office. The Office ID could then be saved using an OnSave event handler.

Related

Basic List on Entity Form

In Dynamics CRM online, I can add a list of entities to another entity, for example a list of products to an opportunity.
Is there any way I can have a list that is not picked from pre-populated items, e.g. just a simple list of {number, date, text} that you type in each time you want to add to the list, not picking items from a pre-defined list.
I am just using the web interface to customise at the moment, but I am open to any suggestions.
EDIT:
So far i have;
Created two entities, proposal and proposal version
Added a 1:N relationship between proposal and proposal version
Added a sub-grid to the proposal form, tried to make it editable but it refuses to work
This lets me add new rows by opening up the proposal version form and adding a new one or picking from already created ones for other proposals but that is rather clunky for a simple list.
I don't want it to offer to search for previous entries, just let me add to the list by typing stuff in, surely this should be fairly simple?
If you want a pre-defined list of items that are simple (number, date, text..) then you can create an option set field in CRM. These lists are fixed and can only be extended by customising the system. An example option set field might be Organisation Type:
Prospect
Site
Head Office
...
If you want a pre-defined list that can be extended, you need to create a new entity. Following from the previous example, you would create a custom entity called Organisation Type and then create a record for each type you wanted, populating only the name field with the type: Prospect, Site etc.
Then you would add a lookup field pointing to the Organisation Type entity on any other entity that used the field, such as Organisation (Account).
You see how the custom entity still appears as simple data because you're only populating the name field, which can be text, a number etc. You can also apply security roles to this entity, limiting which users can create and delete options from your list.
Edit: to only allow the creation of new records in a subgrid, make sure the lookup attribute to the parent entity on the child entity is business required.

Multiplechoice widget with really big lsit

In my model Person can have more than one partner, so the ManyToMany Model is the only answer (this has to be ManyToMany for other reasons, so please don't think about changing it).
If I use default widget i got a list of all persons with selected one, two maybe three persons (which are partners of Person).
It would be ok, if the Person list is about 10-100 - and it works on test database. But my prod database has 10.000 persons or more, so the ModelMultipleChoice widget would be filled with 10.000 records, and finding the correct partner will last ages, and memory usage isn't trivial.
I need only to see names of partners with possibility to unset it from person, and some possibility to add new just typing name. The best solution is to show listbox with filtered names after typing three or four first letters, but any solution would be great.
With forms it would be easier, but I need it in admin, so I'd like to use django admin standards.

Opencart set Store preferences

In Opencart we have the following type of products.
Printed Books (hard copies) which will be shipped to customer.
For the same we have Digital Downloads.
We want an option set at the store level whether user wants to see Downloads or Printed Copies.
When the user chooses downloads option, it should display only downloadable products in all the categories.
When user chooses Printed Copies, it should display only printed products in each of the categories.
Any suggestions to achieve this functionality are welcome.
Thanks
"Any suggestions to achieve this functionality"
From my point of view (which may not be optimal) we need:
Permanent storage for the user preference [5 % done]
add a column to the table <DB_PREFIX>customer with a type of INT and a value of 0 if the user is interested in all products, 1 for digital downloads and so on..., if there is a possibility that you will add new preferences later, then it's better to store a serialized version of all the user preferences in a column of type TEXT
A way to retrieve user preference [25 % done]
you can just retrieve it from the database every time you need it, a better way is to keep it in the session at the same way the user data (like address, telephone)in the class User is kept
A way to change the user preference [40 % done]
some check box in the user settings page, it's also preferable (UX wise) that the user preference is shown in the header next to his name and can be edited directly from there
And finally, displaying products based on that preference [100 % done :D]
you will need to change some code in the controller of the category page, best seller module, latest products .... (any module that involves displaying products)
Simple, naive and ugly solution:you will notice that there is a code segment that copies products data to the view data, it looks like
$data['products'][] = array( in OC 2.X and $this->data['products'][] = array( for versions prior to OC 2, a simple if condition here will be enough, just check for the user preference and decide accordingly whether to copy the product to the view data or not
Better solution: filter products based on the user preference from the very beginning in the model functions, add an extra optional parameter to all model functions that retrieves products (don't forget those functions that retrieves products count) that indicates the user preference, check inside model functions if the parameter is set then do you work in the query

Creating User Generated Models and SQL Tables in Ruby on Rails 4

Considering scenario of an Inventory Management System. Inventory has many types of items, each with own table and columns. One, two or Twelve tables are not sufficient to describe the plethora of the TYPES of items as they are extremely varying. e.g. some attributes of a family of items like BIKES do not have the same attributes of CARS. It is tedious for developer to take into account the thousands of the TYPES of items and incorporate them into each model manually.
Is there a way for users to generate models themselves? thereby generating own SQL tables etc... Is there another approach to this problem? (Maybe using Semantic Web Technologies)
Coming from Spring Framework, I am fairly new to RoR development.
Thanks in Advance.
I'm not an expert, but you could do it with regular, pre-defined models.
Item_Type
Item_Attribute
Item
Item_Type would have a name variable (not unique), and perhaps any other common attributes you'd want. It would then have a has_many Item_Attributes relationship, whereas Item_Attribute belongs_to Item_Type.
So I'd make a view that allows the user to add new Item_Types and then define Item_Attributes for those item types.
Then you could have the actual Item model, each instance of which is the existence of an Item_Type in the inventory. Item belongs to Item_Type, and Item_Type has_many Items, and Item cannot have a null Item_Type.
So a user creates a new Item_Type with the name "BIKE", then adds several Item_Attributes to it, such as "Mountain" and "Red". Then the user can create a new Item that has a relationship to the "BIKE" Item_Type.
If they wanted to add a blue mountain bike instead of a red one, they would need to go through the process again, adding another Item_Type of "BIKE" except adding "Blue" as an attribute for the new instance of Item_Type's Item_Attributes.

Filter external list fields from client

BACKGROUND:
We’re developing a custom application which access SharePoint through the Client Object Model and this application need to access ECT (external content type) lists defined in SharePoint using the OM (Object Model). This application is a product that should be usable with most SharePoint installations and configuration and cannot have prior knowledge of External Lists.
When there are no filters set up for the ECT, SharePoint returns all the available items in the list (given the number is below the threshold). The moment we define a filter for this ECT, SharePoint return only the items after this filter is applied (probably correct behaviour from SP).
PROBLEM:
We need to be able to search this ECT list (non-filtered) based on text entered by a user in a search box. At the moment there seem to be no way to change the filter SharePoint applied when returning the values to the calling object.
I.e. I have 10 items in my ECT list (1,2,3…10). Each Item has 3 columns (ID, Name, Description). After setting up a filter for the ECT list, SharePoint return items 2, 3 & 6 when I ask SharePoint for a list of items.
No the user does a search the matches the description of item 7. How can I search/filter the list to return the item that match my search query?
I’ve been running in circles trying to solve this, but nothing seem to work. I tried setting the CAML query as well as the LoadQuery as defined in both http://pholpar.wordpress.com/2011/02/09/how-to-query-external-lists-on-the-client-side-using-caml/ and http://msdn.microsoft.com/en-us/library/ff464384.aspx but nothing seem to work.
Even I had this problem. Let me tell you there is no way of doing this.
Even in Server object model, there was an option to change the filters of the default view but then the SPList will return 0 items once the filter is applied.
The funny part is once your code runs & you open the list in SP UI, you can see the actual modified list. But the same cannot be queries in the object model.
Looks strange. I guess if you modify the SPList (ECT based) in this instance, then you can only get results in the next instance (like in next page refresh.....)