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

Object Oriented Menus Proposal #89

Open
mvastola opened this issue Jul 5, 2013 · 2 comments
Open

Object Oriented Menus Proposal #89

mvastola opened this issue Jul 5, 2013 · 2 comments

Comments

@mvastola
Copy link

mvastola commented Jul 5, 2013

Hi,
I just wanted to touch base and see if the following functionality would be approved as a patch to this code base as I am planning to code it regardless and I want to gear it towards either being plugged directly into Highline or being its own add-on gem. (If the former is possible, I think it's important I talk to you guys beforehand to ensure I meet whatever constraints you want to impose.)

Basically, I want to code a way for something like this (input/output from use of 'checkinstall' menu editor) as the end result, but on the way there, a lot of features could easily be added that I think could make highline a bit more robust than it already is, for instance with wizards/workflows to fully describe the variables to be set in a class. Here's the screenshot:
Checkinstall Menu Editor

Basically:
I want the ability to see all the values for an object at a glance and be able to set any one of them individually. (If this is done, it's an insignificant amount of work to have the added feature of prompting for each value in sequence.) The only thing that this screenshot doesn't show that I'd like is the ability to abort changing a field, and also to re-set it to the default value.

I think the way I want to implement this is to accept classes that have some sort of ActiveModel-type class interface (though I would want this to be agnostic in terms of dependencies or the model's inhereted attributes, so I would just expect the provided class to respond to certain functions).

The benefit of this, is if "include Highline::Model" is added to the model, we can design our own methods like Model.wizard or Model.menu that could be called on it.

Any model would only need to have the following functionality defined:

  • A method returning list of the attributes to be set.
  • A method to set a given attribute to a given value.

We could additionally accept, but not require, the following methods to that model for more advanced features: (Say the column in question is 'name'.)

  • #name_default -- will show up between square brackets at the prompt and will be assumed as the answer if no input is provided.
  • #name_hide? -- will make an attribute /not/ appear either for the wizard, each redraw of the menu or both (depending on return value), if, for instance, a specific answer to another value has rendered the choice moot.
  • Compatibility with include ActiveModel::Validations for validations or a custom-implemented model with a similar interface. For instance, #name_validates? could be called on setting any attribute to accept/reject the value and, if accepted, #validate could be called on the record after any attribute is changed for the purpose of obtaining an array of warnings/errors for the console to list if any attributes are incompatible with each other.
  • Compatibility with the 'simple_enum' gem (or similar custom implementation). This would turn any field into an enumerated list of choices rather than free-response-type input.
  • Compatibility with 'ActiveAttr' gem (or similar implementation) for typecasting (and setting default values).
  • Compatibility with ActiveModel::SecurePassword (for instance by not echoing input when taking values for this field.)
  • Compatibility with ActiveModel::Dirty (for instance by selectively showing the save button).

Please let me know what you guys think.

@JEG2
Copy link
Owner

JEG2 commented Jul 5, 2013

If I am understanding the request correctly, you want to add a feature where HighLine basically builds a menu system for modifying the properties of some object. Sure. This seems like a fine add on. I have no problem with adding it.

@JEG2
Copy link
Owner

JEG2 commented Feb 5, 2015

We are currently planning the next major version of HighLine. We will include a discussion of this issue in the plans we make for that release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants