pwix:app-pages-edit
What is it ?
A package which extends the pwix:app-pages packages to let an application manage inline-editable documents:
-
extends the AppPages.DisplayUnit class to have an
editionAllowed()method and awantEditionSwitchproperty -
extends the AppPages.RunContext class to have
editDisplayUnitWantSwitch(),editUserAllowed()andeditionAsked()methods.
Features
When an application wants to manage inline editable documents, following features are managed:
-
a switch button is available and let the user edit the document; this button may be hidden or disabled, on or off
-
a Blaze component is available and let the user visually edit the document
-
a storage collection is used to record the document depending of the chosen language.
Installation
This Meteor package is installable with the usual command:
meteor add pwix:app-pages-edit meteor npm install lodash --save
How does this work ?
At the application level
On a per-environment basis, the developer may decide to activate or not the inline-editable feature by having a wantEditionSwitch parameter set to true in the application settings for the environment.
When the parameter is false or not set, this package nonetheless honors (displays) the inline-edited documents found in the database.
At the display unit level
A wantEditionSwitch must be set to true in each display unit which wants take advantage of this feature. This is only considered if the eponym environment settings is itself set to true. When the display unit property is false, which is the default, the edition switch can be hidden, or shown and disabled, depending of the relevant configuration parameter.
When both switches are true (i.e. for the application's display unit in the current environment), the user must be allowed to edit this particular page. This is the function of the configured allowFn() function. When the user is not allowed, the edition switch can be hidden, or shown and disabled, depending of the relevant configuration parameter.
Provides
AppPagesEdit
The exported AppPagesEdit global object provides following items:
Functions
AppPagesEdit.configure()
See below.
A reactive data source.
AppPagesEdit.environmentWantSwitch()
Whether the environment settings have defined a wantEditionSwitch to true, defaulting to false.
A reactive data source.
AppPagesEdit.i18n.namespace()
Returns the i18n namespace used by the package. Used to add translations at runtime.
AppPages.DisplayUnit extension
The AppPages.DisplayUnit class is extended with:
-
wantEditionSwitch: BooleanpropertyWhether the display unit supports the inline edition, defaulting to
false. -
async editionAllowed(): BooleanmethodWhether the current user is allowed to edit the current display unit, defaulting to
false.Remind that this requires too that both the environment and the display unit have a
wantEditionSwitchproperty set totrue.A reactive data source.
AppPages.RunContext extension
The AppPages.RunContext class is extended with:
-
editDisplayUnitWantSwitch(): BooleanmethodWhether the current display unit wants an edition switch.
A reactive data source.
-
editUserAllowed(): BooleanmethodWhether the currently connect user is allowed to edit the current display unit.
A reactive data source.
-
async editionAsked(): BooleanmethodWhether the current user has asked to edit the current display unit.
A reactive data source.
Blaze components
AppPagesEditButton
Displays (or not) a toggle button to let the user enter in edition mode on the current page.
The component is configurable through the package configuration as this is considered as an application-level component.
Default is to:
-
only display the button if environment wants an edition switch
-
only enable the button if display unit wants an edition switch, and an allowed user is connected.
In other words, the toggle button can be:
-
displayed and enabled,
-
displayed and disabled if:
- no user is connected, and
hiddenIfNotConnectedis nottrue, - a user is connected but is not allowed to edit, and
hiddenIfNotAllowedis nottrue, - the display unit doesn't want an edition switch, and
hiddenIfDisplayUnitDoesntWantis nottrue, - the running environment doesn't want an edition switch, and
hiddenIfEnvironmentDoesntWantis nottrue.
- no user is connected, and
-
hidden.
AppPagesEditList
Encapsulates the teManagerExt component to render a tabbed tabular display.
Parms are:
-
collections: a string or an array of strings of the known documents collections, -
languages: a string or an array of strings of the managed languages.
Because the pwix:app-pages-edit package manages inline-editable documents in <collection>:<language> named collections, we have to provide each part of the expression.
AppPagesEditSerializer
Encapsulates the pwix:editor/teEditor component to manage serialization and multi-languages documents.
The component must be provided with the same parameters than accepted by pwix:editor/teSerializer component:
-
collection: the collection name -
document: the collection name -
collection: the document name -
mode: the edition mode.
Permissions management
This package can take advantage of pwix:permissions package to manage the user permissions through the configured allowFn() function.
Configuration
The package's behavior can be configured through a call to the AppPagesEdit.configure() method, with just a single javascript object argument, which itself should only contains the options you want override.
Known configuration options are:
-
allowFnAn async function which will be called with an action string identifier, and must return whether the current user is allowed to do the specified action.
If the function is not provided, then the default is to deny all editions.
allowFnprototype is:async allowFn( action<String>, user<String|Object>, page<DisplayUnit> ): Boolean -
collectionThe name of the default documents collection(s), defaulting to
te_contents.The collection can be still be modified in the
AppPagesEditSerializerdata context. -
hiddenIfEnvironmentDoesntWantWhether the toggle button must be hidden when the environment doesn't ask for an edition switch.
Defaults to
true: button is hidden.Since v1.3.
-
hiddenIfDisplayUnitDoesntWantWhether the toggle button must be hidden when the display unit doesn't ask for an edition switch.
Defaults to
false: button is displayed.Since v1.3.
-
hiddenIfNotConnectedWhether the toggle button must be hidden when no user is connected.
Defaults to
false: button is displayed.Since v1.3.
-
hiddenIfNotAllowedWhether the toggle button must be hidden when the currently connected user is not allowed to edit the display unit.
Defaults to
false: button is displayed.Since v1.3.
-
toggleHiddenWhenNotConnectedWhether the toggle button must be shown and disabled when user is not connected, or hidden.
Defaults to
true: button is hidden.This attribute is deprecated starting with v1.3.
-
toggleHiddenWhenUnallowedWhether the toggle button must be shown and disabled when user is connected but not allowed, or hidden.
Defaults to
true: button is hidden.This attribute is deprecated starting with v1.3.
-
verbosityDefine the expected verbosity level.
The accepted value can be any or-ed combination of following:
-
AppPagesEdit.C.Verbose.NONEDo not display any trace log to the console.
-
AppPagesEdit.C.Verbose.CONFIGURETrace
AppPagesEdit.configure()calls and their result.This is the default.
-
-
withBadgeWhether to display a small badge on the disabled edition toggle switch to provide a visual reason.
Defaults to
false.Since v1.3.
Please note that AppPagesEdit.configure() method should be called in the same terms both in client and server sides.
Remind too that Meteor packages are instanciated at application level. They are so only configurable once, or, in other words, only one instance has to be or can be configured. Addtionnal calls to AppPagesEdit.configure() will just override the previous one. You have been warned: only the application should configure a package.
NPM peer dependencies
Starting with v 0.1.0, and in accordance with advices from the Meteor Guide, we no more hardcode NPM dependencies in the Npm.depends clause of the package.js.
Instead we check npm versions of installed packages at runtime, on server startup, in development environment.
Dependencies as of v 1.3.0:
1 'lodash': '^4.17.0',
Translations
New and updated translations are willingly accepted, and more than welcome. Just be kind enough to submit a PR on the Github repository.
Cookies and comparable technologies
None at the moment.
Issues & help
In case of support or error, please report your issue request to our Issues tracker.
P. Wieser
- Last updated on 2026, May. 3rd