Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work in progress for context-specific settings #123

Closed
wants to merge 14 commits into from

Conversation

Mark-H
Copy link
Member

@Mark-H Mark-H commented Jan 31, 2017

This is a work in progress pull request, the feature isn't ready yet.

What does it do?

  • Adds the database architecture to support context-specific setting values
  • Updates the caching to follow a new structure that can keep all context values in one cache file for easy lookup
  • Updates the plugin to provide the context-specific values to [[++setting_placeholders]] and $modx->setOption/getOption.
  • Provides an interface to manage context specific values, including a way to switch between context/global values
  • Adds the ability to revert back to the default/global value (Revert/Clear Setting #23)

Why is it needed?

Would bring ClientConfig to a whole new level of usefulness.

Related issue(s)/PR(s)

#4 #112 #23

…che to hold it all, and update the plugin to set context-specific values
@Mark-H
Copy link
Member Author

Mark-H commented Jan 31, 2017

Contributions to this work in progress would be very welcome... in particular I haven't figured out yet how to handle the interface without making things too complex.

My current idea is that there should be a dropdown in the action bar (top right with the save configuration/to admin view buttons) where the user can select a context they have access to (per standard MODX ACLs). That would refresh the page, showing the context-specific values.

An alternative approach and [was approached here]https://forums.modx.com/thread/81490/clientconfig-custom-configuration-cmp-for-clients?page=6#dis-post-490786) where each context becomes a tab in the component, which gets troublesome with a large amount of contexts. And this comment suggests moving the UI to the edit context panel, but I'm not sure if I like that as it gets too close to the real context settings which sounds confusing.

On save, the system would check which values are identical to the default (system) values, and only create records for the ones that are different. This makes it easy to have an inheritance system, because values are assumed to be configured on the system, and overridden per context.

There also needs to be a way to tell a field to revert back to the default (i.e. remove the context-specific record). This can't be "leave it empty", because an empty value can be a valid non-default value, and you may not know the default value either so setting it to that isn't practical either. Likely this means introducing some kind of button or link that resets to the default, but I don't know what yet.

For people who wish to contribute in another way, here's a bountysource link to place a bounty that will help make this rise to the top of my to do list. :P

@lottaar
Copy link

lottaar commented Mar 22, 2017

Hi Mark, how are things going? I'm not able to contribute with anything technical I'm afraid, you're way ahead of me there, but at least I can share my thoughts when it comes to the UI, for what it's worth.

I think putting the contexts in tabs at the top sounds like the way to go. If there's a large number of contexts, this could perhaps be solved in the same way as on resources. In the attached screengrab you can see that arrows appear at the sides to scroll through the tabs when they don't fit on the screen.

Then the tabs you have in the current version of ClientConfig (groups in client view and settings/groups in admin view) could perhaps go vertically on the left, just like Categories do on the Template Variable tab in the screengrab?

skarmavbild 2017-03-22 kl 18 25 27

@Mark-H
Copy link
Member Author

Mark-H commented Mar 24, 2017

Hi @lottaar - I don't have an update since my last post yet, but thanks for taking the time to comment.

I've ruled out the tab approach because it wont scale. Even the modmore site has 7 contexts, which would cause those awkward scroll buttons to appear, and it's also not searchable. So selecting contexts will be done through a dropdown in the top right.

The TV tabs you mention is already an option; there's a setting that allows you to set a horizontal or vertical layout for the setting groups.

What I haven't figured out entirely UI-wise is how to handle each setting and the new features that need to be added to that, most importantly the ability to reset to the default value. TVs sorta have this so maybe I'll just copy that..

@Mark-H
Copy link
Member Author

Mark-H commented Jul 21, 2017

Spent a bit more time on this following another generous contribution to the bountysource. There's now a dropdown in the top right to select a context, which will dynamically update the values in the form. Doesn't work yet with rich text fields (the shown value doesn't get updated), and for some reason there's no spacing between the other buttons and the dropdown, so it looks weird.

The next step would be to update the save processor to change where the values are stored, so they go into cgContextValue objects instead of the cgSetting one.

Might also need to change the combo to use a custom processor so we have a bit more control over what gets returned, so there could be a "clientconfig.contexts" setting or something to control which ones are available.

@Mark-H Mark-H added this to the v2.0 milestone Jul 21, 2017
@Mark-H Mark-H added the Feature label Jul 21, 2017
Conflicts:
	assets/components/clientconfig/js/mgr/sections/home.js
@Mark-H Mark-H mentioned this pull request Jul 25, 2017
…nto the processor so events aren't duplicated needlessly
… settings later) with custom combo, add the context name to the header after selecting a context, and add &context url parameter to the controller to auto select said context
@Mark-H
Copy link
Member Author

Mark-H commented Sep 13, 2017

It's starting to look functional :D

@Mark-H
Copy link
Member Author

Mark-H commented Sep 13, 2017

I've published a first dev build of ClientConfig 2.0 to modmore.com. For anyone looking to try out this new multi context feature, follow the instructions below.

Important

Do not install this on existing client sites or sites you aim to launch soon, as I don't know how fast I can fix issues. Time is limited, so keep using 1.4.x for anything that needs to work. If needed I can push out 1.4.x updates separately from the 2.0 builds.

Be aware that I have not tested the 1.4 to 2.0 migration. I expect that to be fine, as the data model was added to what was already there, but perhaps testing will prove otherwise.

This is a dev build, not a beta. Expect things to be broken. Don't install it if you're not happy with that :)

Known issues

  • Rich text editors don't update when switching between contexts
  • There's no way to toggle between global and context aware configuration yet. I aim for this to be a setting, with a setup option asking the user if they want global or context aware.
  • There are no added ACLs or anything. If a user can see (list/load) a context, they can edit the associated settings. There is also no way to disable access to the global values.
  • ... let me know what you find

Installing via modmore

ClientConfig 2.0.0-dev1 is available only to modmore users that opt-in to the ClientConfig dev builds Pre-releases channel.

If you don't have a modmore.com account yet: sign up and verify your account.

If you don't have modmore set up in your MODX site yet as a package provider, create an api key and follow the instructions shown (also available here) to add it to your package manager.

Next, again on the api keys page, find the api key you're using in the list, and click on ClientConfig 2.0 dev buildsPre-releases in the Channels column to enable the channel for that api key.

Now you can go into the package manager by clicking on the small arrow on the Download Extras button, choosing the Select Package Provider menu item, and clicking modmore in the list. Search for ClientConfig, and it should say version 2.0.0-dev1.

Finally, let me know how it works for you. Missing anything that's not yet on the known issues list earlier in this post? Ideas to make it better? Let me know.

@sebastian-marinescu
Copy link
Contributor

Will test it soon-ish and let you know! Thanks for the updates! :)

@Mark-H Mark-H closed this Oct 3, 2017
@Mark-H
Copy link
Member Author

Mark-H commented Oct 3, 2017

I've fixed the issue with RTEs and added a setting to switch between global and context aware mode. That, for now, concludes the work on this I think. I'll prepare a test release shortly.

Future enhancements can include the permissions set to control who can edit what, for now that is simply tied in with existing context ACLs.

@Mark-H Mark-H deleted the feature-context-values branch October 3, 2017 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants