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 awantEditionSwitch
property -
extends the AppPages.RunContext class to have an
editionAsked()
.
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.
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 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
(for the application's page 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: Boolean
propertyWhether the display unit supports the inline edition, defaulting to false.
-
async editionAllowed(): Boolean
methodWhether 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
wantEditionSwitch
property set to true.A reactive data source.
AppPages.RunContext
extension
The AppPages.RunContext
class is extended with:
-
async editionAsked(): Boolean
methodWhether 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.
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 teEditor
.
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:
-
allowFn
An 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.
allowFn
prototype is:async allowFn( action<String>, user<String|Object>, page<DisplayUnit> ): Boolean
-
collection
The name of the default documents collection(s), defaulting to
contents
.The collection be still be modified in the
AppPagesEditSerializer
data context. -
toggleHiddenWhenNotConnected
Whether the toggle button must be shown and disabled when user is not connected, or hidden.
Defaults to
true
: button is hidden. -
toggleHiddenWhenUnallowed
Whether the toggle button must be shown and disabled when user is connected but not allowed, or hidden.
Defaults to
true
: button is hidden. -
verbosity
Define the expected verbosity level.
The accepted value can be any or-ed combination of following:
-
AppPagesEdit.C.Verbose.NONE
Do not display any trace log to the console
-
AppPagesEdit.C.Verbose.CONFIGURE
Trace
AppPagesEdit.configure()
calls and their result
-
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.2.0:
1 'lodash': '^4.17.0',
'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 2025, Jul. 8th