App-Dochazka-WWW

 view release on metacpan or  search on metacpan

share/js/dochazka-www/dform-init.js  view on Meta::CPAN

// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of SUSE LLC nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// *************************************************************************
//
// app/dform-init.js
//
// Round one of dform initialization (called from app/target-init)
//
"use strict";

define ([
    'current-user',
    'lib',
    'app/emp-lib',
    'app/entries',
    'app/rest-lib',
    'app/sched-lib',
    'app/prototypes',
    'target'
], function (
    currentUser,
    coreLib,
    empLib,
    entries,
    restLib,
    schedLib,
    prototypes,
    target
) {

    return function () {

        target.push('createLastPlusOffset', {
            // before doing any calculations, look up:
            // - employee's schedule
            // - schedule intervals on date
            // - existing intervals on date
            // timerange start will be:
            // - end of last existing interval, if there are existing intervals
            // - start of first schedule interval, if there are schedule intervals
            // - 00:00 otherwise
            // timerange end will be timerange start plus offset
            'name': 'createLastPlusOffset',
            'type': 'dform',
            'menuText': "Last plus offset",
            'title': "Create interval \"last plus offset\"",
            'preamble': "You entered an offset without a start time. Deriving start " +
                        "time from schedule and last existing interval (if any).",
            'aclProfile': 'active',
            'entriesRead': [
                entries.acTaid,
                entries.iNsid,
                entries.iNdateHidden,
                entries.iNactHidden,
                entries.iNschedintvls,
                entries.iNlastexistintvl,
                entries.iNoffset,
                entries.iNlastplusoffset,
                coreLib.emptyLineEntry,
                entries.iNtoBeCreated,
            ],
            'entriesWrite': [
                entries.iNdate,
                entries.iNtimerange,
                entries.iNact,
                entries.iNdesc,
            ],
            'rememberState': true,
            'miniMenu': {
                entries: ['createSingleIntSave'],
            }
        }); // createLastPlusOffset

        target.push('createMultipleInt', {
            'name': 'createMultipleInt',
            'type': 'dform',
            'menuText': 'Create multiple',
            'title': 'Create multiple intervals according to schedule',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field " +
                        "(2) enter month by name (e.g. \"June\") or number (e.g. \"6\"); " +
                        "DEFAULT: current month " +
                        "(3) enter days as " +
                        "an inclusive range (e.g. \"15-18\"), as a comma-separated list (e.g. " +
                        "\"7, 9, 28\"), or as a combination of the two (e.g. \"1, 3-5, 16-20\"); " +
                        "DEFAULT: entire month " +
                        "(4) Use 'Select activity' if you don't know activity code " +
                        '(5) Description is optional',
            'aclProfile': 'active',
            'entriesRead': [
                entries.iNdaterangeBegin,
                entries.iNdaterangeEnd,
                entries.iNyearHidden,
            ],
            'entriesWrite': [
                entries.iNyear,
                entries.iNmonth,
                entries.iNdaylist,
                entries.iNact,
                entries.iNdesc,
            ],
            'rememberState': true,
            'miniMenu': {
                entries: ['selectActivityAction', 'createMultipleIntSave', 'viewIntervalsAction']
            }
        }); // createMultipleInt

        target.push('createNextScheduled', {
            // before doing any calculations, look up/calculate:
            // - employee's schedule
            // - existing intervals on date
            // - schedule intervals on date
            // timerange will be:
            // - first schedule interval that does not conflict/overlap with an existing interval
            'name': 'createNextScheduled',
            'type': 'dform',
            'menuText': "Next scheduled interval",
            'title': "Create interval \"next scheduled\"",
            'aclProfile': 'active',
            'entriesRead': [
                entries.acTaid,
                entries.iNsid,
                entries.iNdateHidden,
                entries.iNactHidden,
                entries.iNschedintvls,
                entries.iNexistintvls,
                entries.iNnextscheduled,
                coreLib.emptyLineEntry,
                entries.iNtoBeCreated,
            ],
            'entriesWrite': [
                entries.iNdate,
                entries.iNtimerange,
                entries.iNact,
                entries.iNdesc,
            ],
            'rememberState': true,
            'miniMenu': {
                entries: ['selectActivityAction', 'createSingleIntSave'],
            }
        }); // createNextScheduled

        target.push('createSingleInt', {
            'name': 'createSingleInt',
            'type': 'dform',
            'menuText': 'Create',
            'title': 'Create an arbitrary interval',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field " +
                        "(2) date YYYY-MM-DD; year is optional " +
                        "(3) time range HH:MM-HH:MM or HH:MM+HH:MM (start time plus offset) " +
                        "or +HH:MM (last existing interval plus offset) or + (next scheduled " +
                        "interval) (4) Use 'Select activity' if you don't know activity code " +
                        '(5) Description is optional',
            'aclProfile': 'active',
            'entriesWrite': [entries.iNdate, entries.iNtimerange, entries.iNact, entries.iNdesc,],
            'rememberState': true,
            'miniMenu': {
                entries: ['selectActivityAction', 'createSingleIntSave']
            }
        }); // createSingleInt

        target.push('createLock', {
            'name': 'createLock',
            'type': 'dform',
            'menuText': 'Create',
            'title': 'Create a Lock',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field ",
            'aclProfile': 'active',
            'entriesWrite': [entries.iNyear, entries.iNmonth,],
            'rememberState': true,
            'miniMenu': {
                entries: ['createLockSave']
            }
        }); // createLock

        target.push('createSingleIntFixedDay', {
            'name': 'createSingleIntFixedDay',
            'type': 'dform',
            'menuText': 'Create',
            'title': 'Create an arbitrary interval',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field " +
                        "(2) time range HH:MM-HH:MM " +
                        "(3) Use 'Select activity' if you don't know activity code " +
                        '(4) Description is optional',
            'aclProfile': 'active',
            'entriesRead': [entries.iNdate,],
            'entriesWrite': [entries.iNtimerangeNoOffset, entries.iNact, entries.iNdesc,],
            'rememberState': true,
            'miniMenu': {
                entries: ['selectActivityAction', 'createSingleIntSave']
            }
        }); // createSingleIntFixedDay

        target.push('displaySingleInt', {
            'name': 'displaySingleInt',
            'type': 'dform',
            'menuText': 'Single interval',
            'title': 'Display a single interval',
            'aclProfile': 'active',
            'entriesRead': [entries.iNdaterange, entries.iNtimerange, entries.iNact, entries.iNdesc,],
            'miniMenu': {
                entries: []
            }
        }); // displaySingleInt

        target.push('empProfile', {
            'name': 'empProfile',
            'type': 'dform',
            'menuText': 'Profile',
            'title': 'Employee profile',
            'preamble': null,
            'aclProfile': 'passerby',
            'entriesRead': [
                entries.ePfullname, entries.ePnick,
                entries.ePsec_id, entries.ePemail,
                entries.ePremark,
                coreLib.emptyLineEntry,
                entries.ePsuperNick, entries.ePhasReports,
                coreLib.emptyLineEntry,
                entries.ePpriv, entries.ePprivEffective,
                coreLib.emptyLineEntry,
                entries.ePscode, entries.ePsid, entries.ePschedEffective
            ],
            'miniMenu': {
                entries: [
                    'actionPrivHistory',
                    'actionSchedHistory',
                    'empProfileEdit',
                    'ldapSync',
                    'empProfileSetSuperSearch',
                    'empProfileSetSuperDelete',
                ]
            }
        }); // empProfile

        target.push('empProfileEdit', {
            'name': 'empProfileEdit',
            'type': 'dform',
            'menuText': 'Edit remark',
            'title': 'Employee profile edit',
            'preamble': 'Only the remark field can be modified;<br>' +
                        'All other fields are synced from LDAP',
            'aclProfile': 'admin',
            'entriesRead': [entries.ePfullname, entries.ePnick,
                entries.ePsec_id, entries.ePemail],
            'entriesWrite': [entries.ePremark],
            'miniMenu': {
                entries: ['empProfileEditSave']
            }
        }); // empProfileEdit

        target.push('empProfileSetSuperConfirm', {
            'name': 'empProfileSetSuperConfirm',
            'type': 'dform',
            'menuText': 'empProfileSetSuperConfirm',
            'title': 'Set employee supervisor - confirmation',
            'preamble': 'Do you really want to do this?',
            'aclProfile': 'admin',
            'entriesRead': [
                entries.ePsetsuperofEID,

share/js/dochazka-www/dform-init.js  view on Meta::CPAN


        target.push('schedNewBoilerplate', {
            'name': 'schedNewBoilerplate',
            'type': 'dform',
            'menuText': 'Boilerplate (quick form for Mon-Fri schedules)',
            'title': 'Create a new schedule - boilerplate',
            'preamble': 'Hint: separate schedule intervals by semi-colon<br>' +
                        'Example: 8:00-12:00; 12:30-16:30<br>' +
                        '<b>Schedule intervals will be replicated for Monday-Friday</b><br>' +
                        'Note: schedule code is optional',
            'aclProfile': 'admin',
            'entriesRead': [entries.sDid],
            'entriesWrite': [entries.sCboiler, entries.sDcode],
            'miniMenu': {
                entries: ['createSchedule']
            }
        }); // schedNewBoilerPlate

        target.push('schedNewCustom', {
            'name': 'schedNewCustom',
            'type': 'dform',
            'menuText': 'Custom (long form)',
            'title': 'Create a new schedule - custom',
            'preamble': 'Hint: separate schedule intervals by semi-colon<br>' +
                        'Example: 8:00-12:00; 12:30-16:30<br>' +
                        'Note: schedule code is optional',
            'aclProfile': 'admin',
            'entriesRead': [entries.sDid],
            'entriesWrite': [entries.sDmon, entries.sDtue,
                             entries.sDwed, entries.sDthu, entries.sDfri,
                             entries.sDsat, entries.sDsun, entries.sDcode],
            'miniMenu': {
                entries: ['createSchedule']
            }
        }); // schedNewCustom

        target.push('searchEmployee', {
            'name': 'searchEmployee',
            'type': 'dform',
            'menuText': 'Search Dochazka employees',
            'title': 'Search Dochazka employees',
            'preamble': 'Enter search key, % is wildcard',
            'aclProfile': 'admin',
            'entriesWrite': [entries.sEnick],
            'miniMenu': {
                entries: ['actionEmplSearch']
            }
        }); // searchEmployee

        target.push('updateSingleInt', {
            'name': 'updateSingleInt',
            'type': 'dform',
            'menuText': 'Update',
            'title': 'Update an interval',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field " +
                        "(2) time range HH:MM-HH:MM " +
                        "(3) Use 'Select activity' if you don't know activity code " +
                        '(4) Description is optional',
            'aclProfile': 'active',
            'entriesRead': [entries.iNdate, entries.acTaid],
            'entriesWrite': [entries.iNtimerangeNoOffset, entries.iNact, entries.iNdesc,],
            'rememberState': true,
            'miniMenu': {
                entries: ['selectActivityAction', 'updateSingleIntSave']
            }
        }); // updateSingleInt

        target.push('viewIntervalsPrep', {
            'name': 'viewIntervalsPrep',
            'type': 'dform',
            'menuText': 'View',
            'title': 'View intervals for date or range of dates',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field " +
                        "(2) enter month by name (e.g. \"June\") or number (e.g. \"6\"); " +
                        "DEFAULT: current month " +
                        "(3) enter days as a singleton (e.g. \"13\") or inclusive range (e.g. \"15-18\") " +
                        "DEFAULT: entire month",
            'aclProfile': 'inactive',
            'entriesRead': [
                entries.iNdaterangeBegin,
                entries.iNdaterangeEnd,
                entries.iNyearHidden,
            ],
            'entriesWrite': [
                entries.iNyear,
                entries.iNmonth,
                entries.iNdayrange,
            ],
            'rememberState': true,
            'miniMenu': {
                entries: ['viewIntervalsAction']
            }
        }); // viewIntervalsPrep

        target.push('viewLocksPrep', {
            'name': 'viewLocksPrep',
            'type': 'dform',
            'menuText': 'View',
            'title': 'View locks',
            'preamble': "Hints: (1) TAB or ENTER to validate and advance to next field " +
                        "(2) enter month by name (e.g. \"June\") or number (e.g. \"6\"); " +
                        "DEFAULT: current month ",
            'aclProfile': 'inactive',
            'entriesWrite': [
                entries.iNyear,
            ],
            'rememberState': true,
            'miniMenu': {
                entries: ['viewLocksAction']
            }
        }); // viewLocksPrep

    }; // return function ()
    
});



( run in 0.756 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )