leomoty / SGPP

41 stars 14 forks source link

Module Settings #82

Closed leomoty closed 9 years ago

leomoty commented 9 years ago

This is the preview we talked, i'll start to work as soon as I am feeling better...

export interface ModuleSettingsOption {
    /**
      * What type this option is, we could also use an enum instead.
      */
    optionType: string;

    /**
      * The explanation for this setting.
      */
    description?: string;

    /**
      * The actual name that will be saved to LocalStorage.
      */
    name: string;

    /**
      * The display value on Settings page.
      */
    displayName: string;

    /**
      * The start value if none, we might even need to store these beforehand on LocalStorage.
      */
    defaultValue?: any;

    /**
      * In case this option depends on another, e.g., a checkbox option could block a textfield one.
      */
    dependsOn?: Array<string>;

    /**
      * The pool of possible values
      */
    possibleValues?: Array<any>;

    /**
      * A custom validation function to check whether this is a valid value. Creating some default ones will be interesting
      */
    validate? (value: any): boolean;
}

/**
  * Module settings
  */
export interface ModuleSettings {

    /**
      * The description for this module.
      **/
    description: string;

    /**
      * The module options. If none, only the enable/disable module would exist.
      */
    options?: Array<ModuleSettingsOption>;

    /**
      * Should we do this? The overall idea is to treat this as if it were a submodule.
      * e.g.: All EndlessScroll* modules should just use "Endless Scroll" and they would get grouped by this rule
      */
    grouping?: string;

    /**
     * Is there any other module that needs to be enabled for this one to work?
     **/
    dependsOn?: Array<string>;
}
leomoty commented 9 years ago

This idea was dumped in favor of #88, it has its own repository under SGPPSettings and is built using Twig templating engine.