cubicweb-relationwidget


Namecubicweb-relationwidget JSON
Version 0.10.0 PyPI version JSON
download
home_pagehttps://forge.extranet.logilab.fr/cubicweb/cubes/cubicweb-relationwidget
SummaryProvide a generic and ergonomic relation widget
upload_time2024-03-20 15:38:25
maintainerNone
docs_urlNone
authorLOGILAB S.A. (Paris, FRANCE)
requires_pythonNone
licenseLGPL
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Summary
-------

This cube provides a generic but ergonomic widget to link an edited
entity to several others for a given relation. It provides:

* a list of checkbox-(de-)selectable related entities

* a mecanism to trigger the display of a pop-up window for each possible
  target entity type of the relation

* in the pop-up window, the end-user can:

  - search (using facets) entities to be linked to the edited entity,
  - display (in a paginated table) and select them (using a checkbox on
    each table line)
  - create a new entity to be linked (can be desactivated)


Usage
-----

Select the relation widget for your relation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can use the two following mecanisms to configure the user interface:

- either `cubicweb.web.uihelper.FormConfig`::

    from cubicweb.web import uihelper
    from cubes.relationwidget.views import RelationFacetWidget

    class MyEntityConfig(uihelper.FormConfig):
          etype = 'MyEntity'
          # Move `my_relation` into the attribute section:
          rels_as_attrs = ('my_relation', )
          # Edit `my_relation` using RelationFacetWidget:
          widgets = dict(
              my_relation=RelationFacetWidget,
          )

- or directly via `uicfg.autoform_field_kwarg`::

    from cubicweb.web.views import uicfg
    from cubes.relationwidget.views import RelationFacetWidget

    # edit the relation as attribute.
    uicfg.autoform_section.tag_subject_of(
        ('MyEntity', 'my_relation', '*'),
        formtype=('main', 'muledit'), section='attributes')

    # add the RelationFacetWidget for `my_relation`
    uicfg.autoform_field_kwargs.tag_subject_of(
        ('MyEntity', 'my_relation', '*'), {'widget': RelationFacetWidget})


Configure it (optional)
~~~~~~~~~~~~~~~~~~~~~~~

If you want to desactivate the ability to create a new entity to be
linked to the edited one, you can do it:

* for a single relation using uicfg again::

      uicfg.autoform_field_kwargs.tag_subject_of(
      ('MyEntity', 'my_relation', '*'),
      {'widget': RelationFacetWidget(no_creation_form=True)})

* application-wide by overriding `SearchForRelatedEntitiesView.has_creation_form`
  to always return False::

      from cubes.relationwidget.view import SearchForRelatedEntitiesView

      class MySearchForRelatedEntitiesView(SearchForRelatedEntitiesView):

          @property
          def has_creation_from(self):
              return False

      def registration_callback(vreg):
          vreg.register_and_register(MySearchForRelatedEntitiesView,
                                     SearchForRelatedEntitiesView)

There is also a `dialog_options` dictionary that can be used to
configure the bootstrap modal window (see
http://getbootstrap.com/javascript/#modals-options)::

      uicfg.autoform_field_kwargs.tag_subject_of(
      ('MyEntity', 'my_relation', '*'),
      {'widget': RelationFacetWidget(dialog_options={'keyboard': False})})

            

Raw data

            {
    "_id": null,
    "home_page": "https://forge.extranet.logilab.fr/cubicweb/cubes/cubicweb-relationwidget",
    "name": "cubicweb-relationwidget",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "LOGILAB S.A. (Paris, FRANCE)",
    "author_email": "contact@logilab.fr",
    "download_url": "https://files.pythonhosted.org/packages/b0/ce/c0c0476b2670e4f78018253ac87631a67729ab739d4000ef487218d22012/cubicweb-relationwidget-0.10.0.tar.gz",
    "platform": null,
    "description": "Summary\n-------\n\nThis cube provides a generic but ergonomic widget to link an edited\nentity to several others for a given relation. It provides:\n\n* a list of checkbox-(de-)selectable related entities\n\n* a mecanism to trigger the display of a pop-up window for each possible\n  target entity type of the relation\n\n* in the pop-up window, the end-user can:\n\n  - search (using facets) entities to be linked to the edited entity,\n  - display (in a paginated table) and select them (using a checkbox on\n    each table line)\n  - create a new entity to be linked (can be desactivated)\n\n\nUsage\n-----\n\nSelect the relation widget for your relation\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nYou can use the two following mecanisms to configure the user interface:\n\n- either `cubicweb.web.uihelper.FormConfig`::\n\n    from cubicweb.web import uihelper\n    from cubes.relationwidget.views import RelationFacetWidget\n\n    class MyEntityConfig(uihelper.FormConfig):\n          etype = 'MyEntity'\n          # Move `my_relation` into the attribute section:\n          rels_as_attrs = ('my_relation', )\n          # Edit `my_relation` using RelationFacetWidget:\n          widgets = dict(\n              my_relation=RelationFacetWidget,\n          )\n\n- or directly via `uicfg.autoform_field_kwarg`::\n\n    from cubicweb.web.views import uicfg\n    from cubes.relationwidget.views import RelationFacetWidget\n\n    # edit the relation as attribute.\n    uicfg.autoform_section.tag_subject_of(\n        ('MyEntity', 'my_relation', '*'),\n        formtype=('main', 'muledit'), section='attributes')\n\n    # add the RelationFacetWidget for `my_relation`\n    uicfg.autoform_field_kwargs.tag_subject_of(\n        ('MyEntity', 'my_relation', '*'), {'widget': RelationFacetWidget})\n\n\nConfigure it (optional)\n~~~~~~~~~~~~~~~~~~~~~~~\n\nIf you want to desactivate the ability to create a new entity to be\nlinked to the edited one, you can do it:\n\n* for a single relation using uicfg again::\n\n      uicfg.autoform_field_kwargs.tag_subject_of(\n      ('MyEntity', 'my_relation', '*'),\n      {'widget': RelationFacetWidget(no_creation_form=True)})\n\n* application-wide by overriding `SearchForRelatedEntitiesView.has_creation_form`\n  to always return False::\n\n      from cubes.relationwidget.view import SearchForRelatedEntitiesView\n\n      class MySearchForRelatedEntitiesView(SearchForRelatedEntitiesView):\n\n          @property\n          def has_creation_from(self):\n              return False\n\n      def registration_callback(vreg):\n          vreg.register_and_register(MySearchForRelatedEntitiesView,\n                                     SearchForRelatedEntitiesView)\n\nThere is also a `dialog_options` dictionary that can be used to\nconfigure the bootstrap modal window (see\nhttp://getbootstrap.com/javascript/#modals-options)::\n\n      uicfg.autoform_field_kwargs.tag_subject_of(\n      ('MyEntity', 'my_relation', '*'),\n      {'widget': RelationFacetWidget(dialog_options={'keyboard': False})})\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "Provide a generic and ergonomic relation widget",
    "version": "0.10.0",
    "project_urls": {
        "Homepage": "https://forge.extranet.logilab.fr/cubicweb/cubes/cubicweb-relationwidget"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ede791768ede9a84daba9dd3cefcd3e1cec620b79a1a01966240abae0bcff2e",
                "md5": "0fcdea0f3407f7eff1984f1a3dc1cb86",
                "sha256": "a582903af208459b69355ea29750b3148a6fe62ae34ceeb5775f0363176b9776"
            },
            "downloads": -1,
            "filename": "cubicweb_relationwidget-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0fcdea0f3407f7eff1984f1a3dc1cb86",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 19478,
            "upload_time": "2024-03-20T15:38:24",
            "upload_time_iso_8601": "2024-03-20T15:38:24.114661Z",
            "url": "https://files.pythonhosted.org/packages/8e/de/791768ede9a84daba9dd3cefcd3e1cec620b79a1a01966240abae0bcff2e/cubicweb_relationwidget-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0cec0c0476b2670e4f78018253ac87631a67729ab739d4000ef487218d22012",
                "md5": "ee26f0a50c08fb287e13391f2318128c",
                "sha256": "9f30abcc42d1537eb360cbc20956d6a68b69ff82505ce0d033e0fccfd11557a7"
            },
            "downloads": -1,
            "filename": "cubicweb-relationwidget-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ee26f0a50c08fb287e13391f2318128c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20468,
            "upload_time": "2024-03-20T15:38:25",
            "upload_time_iso_8601": "2024-03-20T15:38:25.813588Z",
            "url": "https://files.pythonhosted.org/packages/b0/ce/c0c0476b2670e4f78018253ac87631a67729ab739d4000ef487218d22012/cubicweb-relationwidget-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-20 15:38:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "cubicweb-relationwidget"
}
        
Elapsed time: 0.22004s