User:MichaelSchoenitzer/quickpresets

From Wikidata
Jump to navigation Jump to search
Screenshot with the example of a human person. The value 'Citizenship' is greyed out, because is already present.

quickpresets is a User script, that allows you to add common statements with only one click. It is meant to be customizable. You can configure it to present you the presets you use most often with as few clicks as possible.

Installation[edit]

To use this gadget add the following into in your common.js:

importScript( 'User:MichaelSchoenitzer/quickpresets.js' ); //Linkback: [[User:MichaelSchoenitzer/quickpresets.js]]

Configuration[edit]

The tool is configured by creating a js-page (for example quickpresets_settings.js) in your usernamespace and loading it from your common.js before the loading of quickpresets:

importScript( 'User:YourName/quickpresets_settings.js' );
importScript( 'User:MichaelSchoenitzer/quickpresets.js' );

You can start by copying the content of the default config (which shows presets for human (Q5) and software (Q7397)) and modify it as you wish.

The format of the configuration is like this:

quick_props = [
   {
      qid: 5,               // Only apply this preset-block for items with instance of (P31) set to 5
      name: "Human",        // Label that should be shown for this group
      defaults: [           // List all Preset for this group
         {
            name: "Gender",
            pid: 21,        // ID of the property that should be proposed
            values: [       // values of the items that should be proposed for this pid
               {name: "male", qid: 6581097},
               {name: "femal", qid: 6581072},
               {name: "intersexual", qid: 1097630},
               //...
            ]
         },
         {
            name: "Citizenship",
            pid: 27,
            values: [
               {name: "USA", qid: 30},
               {name: "Germany", qid: 183},
               //...
            ]
         },
      ]
   },
   // Next group of presets for another type of items comes here.
]

Tips & tricks:

  • Do not add presets for too many different types since quickpresets will do a sparql-query for every type on every item!
  • You can add presets for items without any instance of (P31) by adding a preset-group where the qid is null
  • You can add presets for items with any arbitrary instance of (P31) by adding a preset-group where the qid is 0
  • The tool will not only work for items with instance of (P31) set to the specified value, but also for value that are a subclass of (P279) of it (incl. recursive applying).
  • The NavelGazer tool can be helpful to identify properties that you use frequently, which may be good candidates for quickpresets.
  • The values array can be empty (e.g. for properties that don't have common values, such as given name (P735)), but it must be present.

Changelog[edit]

  • 2017-12-24: Initial version
  • 2017-12-30: Announce on Wikidata:Project_chat and Wikidata:Tools
  • 2017-12-31: Add Support "no instance of (P31)"
  • 2018-01-01: Add Support "any instance of (P31)"
  • 2018-01-15: Fixed a bug.
  • 2018-02-01: new version
    • New Feature: If adding a instance of (P31) reload the interfaces
    • New Feature: Support properties with datatype string
    • Improvement: Items are now added 3x as fast
    • A few bug-fixes
  • 2018-02-02: Show Properties without presets compactly & Link this site in the edit summary

Bugs & Todos[edit]

  • BUG: Make width identical to the rest
  • BUG: Showing wrong interface on properties
  • i18n
    • multilingual strings
  • Support for other Datatypes
    • Strings -- ✓ OK
    • URL -- ✓ OK (could still be improved)
  • v2: Add interface to allow easily configure own setting – WIP
  • v2: Add properties via Javascript not Api, so that they can be edited without reloading. – WIP, stalled due to an issue
  • v2: Add sources?

See also[edit]

  • Wikidata:Cradle — supports a similar concept of presets (forms), and works for creating new items rather than editing new ones. Note that Cradle's presets are shared.
  • Wikidata:Recoin ("Relative Completeness Indicator") — allows adding statements to an item, based on which statements are most commonly added to similar items.