Extending simple admin interface - How to?

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
andreas.allacher
Posts: 42
Joined: 15 Dec 2015, 20:32

Extending simple admin interface - How to?

Post by andreas.allacher » 24 Aug 2016, 19:13

Hi, I would like to know how exactly one would extend the easy admin interface, e.g. adding customer groups to prices (in combination with the ai-customergroups extension).

I guess I would have to add a subpart via:
admin/jqadm/product/price/standard/subparts

Which implements the corresponding get, save, ... etc. methods and adds its own template.
That way I can then render the select box (multi-select) or via checkboxes for the available groups in my own template which is automatically appended via priceBody to the default template.

And get/save, etc. would would need to take care that the set values are stored correctly to database?

Anything else?

How would I retrieve data via ajax as I think is done for the languages?

Am I correct in assuming that I can retrieve options via the features already implemented in jsonadm, even for customer groups, like .e.g.:
Aimeos.getOptions(request, response, element, 'customer/group', 'customer.group.label', 'customer.group.id', criteria);

And by adding something like:
$(".product-customer-group .combobox").combobox({
getfcn: Aimeos.getOptionsCustomerGroups,
select: Aimeos.Product.CustomerGroup.select
});
and implementing the corresponding Aimeos.getOptionsCustomerGroups javascript method and the corresponding select method?

Anything else or anxthing to do differently?

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Extending simple admin interface - How to?

Post by aimeos » 25 Aug 2016, 10:57

It should be possible like you've described.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

andreas.allacher
Posts: 42
Joined: 15 Dec 2015, 20:32

Re: Extending simple admin interface - How to?

Post by andreas.allacher » 01 Nov 2016, 19:21

Some further questions in that regard.

If I want to add additional text fields to the "Texts".
I have now created a subparted and copied the behavioru of \Aimeos\Admin\JQAdm\Product\Text\Standard
to achieve storage etc. for my own fields.
Then I added a Javascript that moves my subpart code, inside the "Language parts" of the "Texts" rows.

Another solution would be i guess to add a decorator for the client and overwrite the template and directly include the new fields in the template and add the save/get/... methods from my subpart to the decorator.
However, that is still not that easy to achieve because I again have to implement the save/get/... methods for those fields.


Now, I think this should be easier to achieve because basicallly, it only requires additional template information INSIDE the language rows and to add tjhe field to the typeList property. However, the property is private and therefore cannot be modified for the parent methods.

So, I think it would be cool to be able to easily modify that list and to have subparts that are inside the language rows of the text fields. Those should basically only provide the HTML code because the save / get is already done by the existing class.

Or it should at least be possible to define the typeList property by configuration settings, then one would only have to modify the template to get everything to work.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Extending simple admin interface - How to?

Post by aimeos » 01 Nov 2016, 23:01

You are right, extending the list of text types should be easier, especially as this might be an often requirement. These two commits make it possible:
- https://github.com/aimeos/ai-admin-jqad ... 2e72813cf6
- https://github.com/aimeos/ai-admin-jqad ... f0e40ab4b5

Unfortunately, moving the sub-template inside the panels don't work. This would make it very easy but we need two template parts: One for existing languages and one for new ones (prototype)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

andreas.allacher
Posts: 42
Joined: 15 Dec 2015, 20:32

Re: Extending simple admin interface - How to?

Post by andreas.allacher » 02 Nov 2016, 17:35

That will make it way easier already, however, I think moving the subparts to inside the panels would be nice though, for e.g. other fields like prices. If I want to add fields I want to do so per currency.
The change is for master / 2017.x release only?

Or provide a data attribute that moves it automatically to the correct position with Javascript which should be enough too.

What about a subpart that returns an array of strings or an object with getNew and getLanguage data?

I think the Javascript solution with the data-attribute would be enoug, after all the backend will not work without it anyway :)
Maybe with an example inside the template on how to use it.
Last edited by andreas.allacher on 02 Nov 2016, 19:13, edited 1 time in total.

User avatar
aimeos
Administrator
Posts: 7836
Joined: 01 Jan 1970, 00:00

Re: Extending simple admin interface - How to?

Post by aimeos » 02 Nov 2016, 19:13

We think it's better to overwrite the template to achieve this instead of making the system too complex.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

andreas.allacher
Posts: 42
Joined: 15 Dec 2015, 20:32

Re: Extending simple admin interface - How to?

Post by andreas.allacher » 02 Nov 2016, 19:14

OK. But the Javascript data attribute solution would be quite simple to achieve too without making the system too complex. Of course, one can write the corresponding Javascript too, after all it is a really simple script, bascially find elements with data-attribute and appendTo to the specified container (for the new prototype and the existing rows).
Overwriting the template is OK too though, except if multiple extensions want to do it :)

Post Reply