pwix:notes
What is it ?
A Meteor package which manages notes:
- add a SimpleSchema to the collection
- provide a template to manage notes indicator in a tabular list
- provide a template to enter notes as an input panel.
Installation
This Meteor package is installable with the usual command:
meteor add pwix:notes
Usage
1 import { Notes } from 'meteor/pwix:notes'; 2 3 // add a standard notes to a collection 4 // inside your `Field.Set` definition 5 Notes.fieldDef() 6 7 // add several notes 8 // inside your `Field.Set` definition 9 Notes.fieldDef({ 10 name: 'adminNotes', 11 dt_title: pwixI18n.label( I18N, 'list.admin_notes_th' ), 12 form_title: pwixI18n.label( I18N, 'tabs.admin_notes_title' ) 13 }), 14 Notes.fieldDef({ 15 name: 'userNotes', 16 dt_title: pwixI18n.label( I18N, 'list.user_notes_th' ), 17 form_title: pwixI18n.label( I18N, 'tabs.user_notes_title' ) 18 })
Provides
Notes
The exported Notes
global object provides following items:
Functions
Notes.configure()
See below.
Notes.fieldDef( [o] )
Returns an object suitable for a Field.Def
definition, as the following default definition:
1 name: Notes.configure().name, 2 type: String, 3 optional: true, 4 dt_title: pwixI18n.label( I18N, 'dt_title' ), // defaulting to 'Notes' 5 dt_template: Meteor.isClient && Template.NotesTd, 6 dt_templateContext( rowData ){ 7 return { 8 item: rowData 9 }; 10 }, 11 form_title: pwixI18n.label( I18N, 'form_title' ), // to caller disposition, the title of a nav tab for example 12 form_label: pwixI18n.label( I18N, 'form_label' ), // the label on the left column of the NotesEdit input table 13 form_placeholder: pwixI18n.label( I18N, 'form_placeholder' ) // the corresponding placeholder
The optional argument may override any part of this default.
This function MUST be called from common code.
Notes.i18n.namespace()
Returns the i18n namespace used by the package. Used to add translations at runtime.
Available both on the client and the server.
Blaze components
NotesTd
This component is automatically included in the tabular display as soon as you have defined the Field.Def
field in your Field.Set
.
NotesEdit
This component provides a TEXTAREA
node inside of a DIV
.
It is meant to be included, for example inside of a tabbed panel.
The component reacts to each input
event by trigerring a notes-data
event with following data:
1 { 2 ...template_context 3 content: instance.$( event.target ).val(), // the current content of the textarea 4 }
More, the component auto-updates the provided item.
The provided data context must include:
-
item
: the edited document, either a raw document or a ReactiveVar -
field
: theField.Def
definition of the field
Configuration
The package's behavior can be configured through a call to the Notes.configure()
method, with just a single javascript object argument, which itself should only contains the options you want override.
Known configuration options are:
-
name
The name of the field to be added to the collections.
Defaults to
notes
. -
verbosity
Define the expected verbosity level.
The accepted value can be any or-ed combination of following:
-
Notes.C.Verbose.NONE
Do not display any trace log to the console
-
Notes.C.Verbose.CONFIGURE
-
Please note that Notes.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 Notes.configure()
will just override the previous one. You have been warned: only the application should configure a package.
Notes.configure()
is a reactive data source.
NPM peer dependencies
Starting with v 0.3.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:
'lodash': '^4.17.0',
Each of these dependencies should be installed at application level:
meteor npm install <package> --save
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 2024, Oct. 4th