diff --git a/core/lib/composer/vendor/bin/export-plural-rules b/core/lib/composer/vendor/bin/export-plural-rules deleted file mode 120000 index d727a051..00000000 --- a/core/lib/composer/vendor/bin/export-plural-rules +++ /dev/null @@ -1 +0,0 @@ -../gettext/languages/bin/export-plural-rules \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/export-plural-rules b/core/lib/composer/vendor/bin/export-plural-rules new file mode 100755 index 00000000..e246599c --- /dev/null +++ b/core/lib/composer/vendor/bin/export-plural-rules @@ -0,0 +1,4 @@ +#!/usr/bin/env php + Enviro::$outputUSAscii)); + } else { + echo call_user_func(array(Exporter::getExporterClassName(Enviro::$outputFormat), 'toString'), $languages, array('us-ascii' => Enviro::$outputUSAscii)); + } +} catch (Exception $x) { + Enviro::echoErr($x->getMessage()."\n"); + Enviro::echoErr("Trace:\n"); + Enviro::echoErr($x->getTraceAsString()."\n"); + die(4); +} + +die(0); + +/** + * Helper class to handle command line options. + */ +class Enviro +{ + /** + * Shall the output contain only US-ASCII characters? + * @var bool + */ + public static $outputUSAscii; + /** + * The output format. + * @var string + */ + public static $outputFormat; + /** + * Output file name. + * @var string + */ + public static $outputFilename; + /** + * List of wanted language IDs; it not set: all languages will be returned. + * @var array|null + */ + public static $languages; + /** + * Reduce the language list to the minimum common denominator. + * @var bool + */ + public static $reduce; + /** + * Parse the command line options. + */ + public static function initialize() + { + global $argv; + self::$outputUSAscii = false; + self::$outputFormat = null; + self::$outputFilename = null; + self::$languages = null; + self::$reduce = null; + $exporters = Exporter::getExporters(); + if (isset($argv) && is_array($argv)) { + foreach ($argv as $argi => $arg) { + if ($argi === 0) { + continue; + } + if (is_string($arg)) { + $argLC = trim(strtolower($arg)); + switch ($argLC) { + case '--us-ascii': + self::$outputUSAscii = true; + break; + case '--reduce=yes': + self::$reduce = true; + break; + case '--reduce=no': + self::$reduce = false; + break; + default: + if (preg_match('/^--output=.+$/', $argLC)) { + if (isset(self::$outputFilename)) { + self::echoErr("The output file name has been specified more than once!\n"); + self::showSyntax(); + die(3); + } + list(, self::$outputFilename) = explode('=', $arg, 2); + self::$outputFilename = trim(self::$outputFilename); + } elseif (preg_match('/^--languages?=.+$/', $argLC)) { + list(, $s) = explode('=', $arg, 2); + $list = explode(',', $s); + if (is_array(self::$languages)) { + self::$languages = array_merge(self::$languages, $list); + } else { + self::$languages = $list; + } + } elseif (isset($exporters[$argLC])) { + if (isset(self::$outputFormat)) { + self::echoErr("The output format has been specified more than once!\n"); + self::showSyntax(); + die(3); + } + self::$outputFormat = $argLC; + } else { + self::echoErr("Unknown option: $arg\n"); + self::showSyntax(); + die(2); + } + break; + } + } + } + } + if (!isset(self::$outputFormat)) { + self::showSyntax(); + die(1); + } + if (isset(self::$languages)) { + self::$languages = array_values(array_unique(self::$languages)); + } + if (!isset(self::$reduce)) { + self::$reduce = isset(self::$languages) ? false : true; + } + } + + /** + * Write out the syntax. + */ + public static function showSyntax() + { + $exporters = array_keys(Exporter::getExporters(true)); + self::echoErr("Syntax: php ".basename(__FILE__)." [--us-ascii] [--languages=[,,...]] [--reduce=yes|no] [--output=] <".implode('|', $exporters).">\n"); + self::echoErr("Where:\n"); + self::echoErr("--us-ascii : if specified, the output will contain only US-ASCII characters.\n"); + self::echoErr("--languages: (or --language) export only the specified language codes.\n"); + self::echoErr(" Separate languages with commas; you can also use this argument\n"); + self::echoErr(" more than once; it's case insensitive and accepts both '_' and\n"); + self::echoErr(" '-' as locale chunks separator (eg we accept 'it_IT' as well as\n"); + self::echoErr(" 'it-it').\n"); + self::echoErr("--reduce : if set to yes the output won't contain languages with the same\n"); + self::echoErr(" base language and rules.\n For instance nl_BE ('Flemish') will be\n"); + self::echoErr(" omitted because it's the same as nl ('Dutch').\n"); + self::echoErr(" Defaults to 'no' --languages is specified, to 'yes' otherwise.\n"); + self::echoErr("--output : if specified, the output will be saved to . If not\n"); + self::echoErr(" specified we'll output to standard output.\n"); + self::echoErr("Output formats\n"); + $len = max(array_map('strlen', $exporters)); + foreach ($exporters as $exporter) { + self::echoErr(str_pad($exporter, $len).": ".Exporter::getExporterDescription($exporter)."\n"); + } + } + /** + * Print a string to stderr. + * @param string $str The string to be printed out. + */ + public static function echoErr($str) + { + $hStdErr = @fopen('php://stderr', 'a'); + if ($hStdErr === false) { + echo $str; + } else { + fwrite($hStdErr, $str); + fclose($hStdErr); + } + } + /** + * Reduce a language list to the minimum common denominator. + * @param Language[] $languages + * @return Language[] + */ + public static function reduce($languages) + { + for ($numChunks = 3; $numChunks >= 2; $numChunks--) { + $filtered = array(); + foreach ($languages as $language) { + $chunks = explode('_', $language->id); + $compatibleFound = false; + if (count($chunks) === $numChunks) { + $categoriesHash = serialize($language->categories); + $otherIds = array(); + $otherIds[] = $chunks[0]; + for ($k = 2; $k < $numChunks; $k++) { + $otherIds[] = $chunks[0].'_'.$chunks[$numChunks - 1]; + } + + foreach ($languages as $check) { + foreach ($otherIds as $otherId) { + if (($check->id === $otherId) && ($check->formula === $language->formula) && (serialize($check->categories) === $categoriesHash)) { + $compatibleFound = true; + break; + } + } + if ($compatibleFound === true) { + break; + } + } + } + if (!$compatibleFound) { + $filtered[] = $language; + } + } + $languages = $filtered; + } + + return $languages; + } +} diff --git a/core/lib/composer/vendor/bin/markdown b/core/lib/composer/vendor/bin/markdown deleted file mode 120000 index 252d9870..00000000 --- a/core/lib/composer/vendor/bin/markdown +++ /dev/null @@ -1 +0,0 @@ -../cebe/markdown/bin/markdown \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/markdown b/core/lib/composer/vendor/bin/markdown new file mode 100755 index 00000000..f8893e05 --- /dev/null +++ b/core/lib/composer/vendor/bin/markdown @@ -0,0 +1,170 @@ +#!/usr/bin/env php + ['cebe\\markdown\\GithubMarkdown', __DIR__ . '/../GithubMarkdown.php'], + 'extra' => ['cebe\\markdown\\MarkdownExtra', __DIR__ . '/../MarkdownExtra.php'], +]; + +$full = false; +$src = []; +foreach($argv as $k => $arg) { + if ($k == 0) { + continue; + } + if ($arg[0] == '-') { + $arg = explode('=', $arg); + switch($arg[0]) { + case '--flavor': + if (isset($arg[1])) { + if (isset($flavors[$arg[1]])) { + require($flavors[$arg[1]][1]); + $flavor = $flavors[$arg[1]][0]; + } else { + error("Unknown flavor: " . $arg[1], "usage"); + } + } else { + error("Incomplete argument --flavor!", "usage"); + } + break; + case '--full': + $full = true; + break; + case '-h': + case '--help': + echo "PHP Markdown to HTML converter\n"; + echo "------------------------------\n\n"; + echo "by Carsten Brandt \n\n"; + usage(); + break; + default: + error("Unknown argument " . $arg[0], "usage"); + } + } else { + $src[] = $arg; + } +} + +if (empty($src)) { + $markdown = file_get_contents("php://stdin"); +} elseif (count($src) == 1) { + $file = reset($src); + if (!file_exists($file)) { + error("File does not exist:" . $file); + } + $markdown = file_get_contents($file); +} else { + error("Converting multiple files is not yet supported.", "usage"); +} + +/** @var cebe\markdown\Parser $md */ +$md = new $flavor(); +$markup = $md->parse($markdown); + +if ($full) { + echo << + + + + + + +$markup + + +HTML; +} else { + echo $markup; +} + +// functions + +/** + * Display usage information + */ +function usage() { + global $argv; + $cmd = $argv[0]; + echo <<] [--full] [file.md] + + --flavor specifies the markdown flavor to use. If omitted the original markdown by John Gruber [1] will be used. + Available flavors: + + gfm - Github flavored markdown [2] + extra - Markdown Extra [3] + + --full ouput a full HTML page with head and body. If not given, only the parsed markdown will be output. + + --help shows this usage information. + + If no file is specified input will be read from STDIN. + +Examples: + + Render a file with original markdown: + + $cmd README.md > README.html + + Render a file using gihtub flavored markdown: + + $cmd --flavor=gfm README.md > README.html + + Convert the original markdown description to html using STDIN: + + curl http://daringfireball.net/projects/markdown/syntax.text | $cmd > md.html + + +[1] http://daringfireball.net/projects/markdown/syntax +[2] https://help.github.com/articles/github-flavored-markdown +[3] http://michelf.ca/projects/php-markdown/extra/ + +EOF; + exit(1); +} + +/** + * Send custom error message to stderr + * @param $message string + * @param $callback mixed called before script exit + * @return void + */ +function error($message, $callback = null) { + $fe = fopen("php://stderr", "w"); + fwrite($fe, "Error: " . $message . "\n"); + + if (is_callable($callback)) { + call_user_func($callback); + } + + exit(1); +} diff --git a/core/lib/composer/vendor/bin/phpunit b/core/lib/composer/vendor/bin/phpunit deleted file mode 120000 index 2c489303..00000000 --- a/core/lib/composer/vendor/bin/phpunit +++ /dev/null @@ -1 +0,0 @@ -../phpunit/phpunit/phpunit \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/phpunit b/core/lib/composer/vendor/bin/phpunit new file mode 100755 index 00000000..8271fa34 --- /dev/null +++ b/core/lib/composer/vendor/bin/phpunit @@ -0,0 +1,53 @@ +#!/usr/bin/env php + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +if (version_compare('7.0.0', PHP_VERSION, '>')) { + fwrite( + STDERR, + sprintf( + 'This version of PHPUnit is supported on PHP 7.0 and PHP 7.1.' . PHP_EOL . + 'You are using PHP %s (%s).' . PHP_EOL, + PHP_VERSION, + PHP_BINARY + ) + ); + + die(1); +} + +if (!ini_get('date.timezone')) { + ini_set('date.timezone', 'UTC'); +} + +foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/../vendor/autoload.php', __DIR__ . '/vendor/autoload.php') as $file) { + if (file_exists($file)) { + define('PHPUNIT_COMPOSER_INSTALL', $file); + + break; + } +} + +unset($file); + +if (!defined('PHPUNIT_COMPOSER_INSTALL')) { + fwrite( + STDERR, + 'You need to set up the project dependencies using Composer:' . PHP_EOL . PHP_EOL . + ' composer install' . PHP_EOL . PHP_EOL . + 'You can learn all about Composer on https://getcomposer.org/.' . PHP_EOL + ); + + die(1); +} + +require PHPUNIT_COMPOSER_INSTALL; + +PHPUnit\TextUI\Command::main(); diff --git a/core/lib/composer/vendor/bin/robo b/core/lib/composer/vendor/bin/robo deleted file mode 120000 index 701d42dd..00000000 --- a/core/lib/composer/vendor/bin/robo +++ /dev/null @@ -1 +0,0 @@ -../consolidation/robo/robo \ No newline at end of file diff --git a/core/lib/composer/vendor/bin/robo b/core/lib/composer/vendor/bin/robo new file mode 100755 index 00000000..2093bd11 --- /dev/null +++ b/core/lib/composer/vendor/bin/robo @@ -0,0 +1,22 @@ +#!/usr/bin/env php +setSelfUpdateRepository('consolidation/robo'); +$statusCode = $runner->execute($_SERVER['argv']); +exit($statusCode); diff --git a/core/lib/composer/vendor/pear/net_smtp/README.rst b/core/lib/composer/vendor/pear/net_smtp/README.rst deleted file mode 120000 index 753c5b5c..00000000 --- a/core/lib/composer/vendor/pear/net_smtp/README.rst +++ /dev/null @@ -1 +0,0 @@ -docs/guide.txt \ No newline at end of file diff --git a/core/lib/composer/vendor/pear/net_smtp/README.rst b/core/lib/composer/vendor/pear/net_smtp/README.rst new file mode 100644 index 00000000..a0e61dbd --- /dev/null +++ b/core/lib/composer/vendor/pear/net_smtp/README.rst @@ -0,0 +1,267 @@ +====================== + The Net_SMTP Package +====================== + +-------------------- + User Documentation +-------------------- + +:Author: Jon Parise +:Contact: jon@php.net + +.. contents:: Table of Contents +.. section-numbering:: + +Dependencies +============ + +The ``PEAR_Error`` Class +------------------------ + +The Net_SMTP package uses the `PEAR_Error`_ class for all of its `error +handling`_. + +The ``Net_Socket`` Package +-------------------------- + +The Net_Socket_ package is used as the basis for all network communications. +Connection options can be specified via the `$socket_options` construction +parameter:: + + $socket_options = array('ssl' => array('verify_peer_name' => false)); + $smtp = new Net_SMTP($host, null, null, false, 0, $socket_options); + +**Note:** PHP 5.6 introduced `OpenSSL changes`_. Peer certificate verification +is now enabled by default. Although not recommended, `$socket_options` can be +used to disable peer verification (as shown above). + +.. _OpenSSL changes: http://php.net/manual/en/migration56.openssl.php + +The ``Auth_SASL`` Package +------------------------- + +The `Auth_SASL`_ package is an optional dependency. If it is available, the +Net_SMTP package will be able to support the DIGEST-MD5_ and CRAM-MD5_ SMTP +authentication methods. Otherwise, only the LOGIN_ and PLAIN_ methods will +be available. + +Error Handling +============== + +All of the Net_SMTP class's public methods return a PEAR_Error_ object if an +error occurs. The standard way to check for a PEAR_Error object is by using +`PEAR::isError()`_:: + + if (PEAR::isError($error = $smtp->connect())) { + die($error->getMessage()); + } + +.. _PEAR::isError(): http://pear.php.net/manual/en/core.pear.pear.iserror.php + +SMTP Authentication +=================== + +The Net_SMTP package supports the SMTP authentication standard (as defined +by RFC-2554_). The Net_SMTP package supports the following authentication +methods, in order of preference: + +.. _RFC-2554: http://www.ietf.org/rfc/rfc2554.txt + +DIGEST-MD5 +---------- + +The DIGEST-MD5 authentication method uses `RSA Data Security Inc.`_'s MD5 +Message Digest algorithm. It is considered the most secure method of SMTP +authentication. + +**Note:** The DIGEST-MD5 authentication method is only supported if the +AUTH_SASL_ package is available. + +.. _RSA Data Security Inc.: http://www.rsasecurity.com/ + +CRAM-MD5 +-------- + +The CRAM-MD5 authentication method has been superseded by the DIGEST-MD5_ +method in terms of security. It is provided here for compatibility with +older SMTP servers that may not support the newer DIGEST-MD5 algorithm. + +**Note:** The CRAM-MD5 authentication method is only supported if the +AUTH_SASL_ package is available. + +LOGIN +----- + +The LOGIN authentication method encrypts the user's password using the +Base64_ encoding scheme. Because decrypting a Base64-encoded string is +trivial, LOGIN is not considered a secure authentication method and should +be avoided. + +.. _Base64: http://www.php.net/manual/en/function.base64-encode.php + +PLAIN +----- + +The PLAIN authentication method sends the user's password in plain text. +This method of authentication is not secure and should be avoided. + +Secure Connections +================== + +If `secure socket transports`_ have been enabled in PHP, it is possible to +establish a secure connection to the remote SMTP server:: + + $smtp = new Net_SMTP('ssl://mail.example.com', 465); + +This example connects to ``mail.example.com`` on port 465 (a common SMTPS +port) using the ``ssl://`` transport. + +.. _secure socket transports: http://www.php.net/transports + +Sending Data +============ + +Message data is sent using the ``data()`` method. The data can be supplied +as a single string or as an open file resource. + +If a string is provided, it is passed through the `data quoting`_ system and +sent to the socket connection as a single block. These operations are all +memory-based, so sending large messages may result in high memory usage. + +If an open file resource is provided, the ``data()`` method will read the +message data from the file line-by-line. Each chunk will be quoted and sent +to the socket connection individually, reducing the overall memory overhead of +this data sending operation. + +Header data can be specified separately from message body data by passing it +as the optional second parameter to ``data()``. This is especially useful +when an open file resource is being used to supply message data because it +allows header fields (like *Subject:*) to be built dynamically at runtime. + +:: + + $smtp->data($fp, "Subject: My Subject"); + +Data Quoting +============ + +By default, all outbound string data is quoted in accordance with SMTP +standards. This means that all native Unix (``\n``) and Mac (``\r``) line +endings are converted to Internet-standard CRLF (``\r\n``) line endings. +Also, because the SMTP protocol uses a single leading period (``.``) to signal +an end to the message data, single leading periods in the original data +string are "doubled" (e.g. "``..``"). + +These string transformation can be expensive when large blocks of data are +involved. For example, the Net_SMTP package is not aware of MIME parts (it +just sees the MIME message as one big string of characters), so it is not +able to skip non-text attachments when searching for characters that may +need to be quoted. + +Because of this, it is possible to extend the Net_SMTP class in order to +implement your own custom quoting routine. Just create a new class based on +the Net_SMTP class and reimplement the ``quotedata()`` method:: + + require 'Net_SMTP.php'; + + class Net_SMTP_custom extends Net_SMTP + { + function quotedata($data) + { + /* Perform custom data quoting */ + } + } + +Note that the ``$data`` parameter will be passed to the ``quotedata()`` +function `by reference`_. This means that you can operate directly on +``$data``. It also the overhead of copying a large ``$data`` string to and +from the ``quotedata()`` method. + +.. _by reference: http://www.php.net/manual/en/language.references.pass.php + +Server Responses +================ + +The Net_SMTP package retains the server's last response for further +inspection. The ``getResponse()`` method returns a 2-tuple (two element +array) containing the server's response code as an integer and the response's +arguments as a string. + +Upon a successful connection, the server's greeting string is available via +the ``getGreeting()`` method. + +Debugging +========= + +The Net_SMTP package contains built-in debugging output routines (disabled by +default). Debugging output must be explicitly enabled via the ``setDebug()`` +method:: + + $smtp->setDebug(true); + +The debugging messages will be sent to the standard output stream by default. +If you need more control over the output, you can optionally install your own +debug handler. + +:: + + function debugHandler($smtp, $message) + { + echo "[$smtp->host] $message\n"; + } + + $smtp->setDebug(true, "debugHandler"); + + +Examples +======== + +Basic Use +--------- + +The following script demonstrates how a simple email message can be sent +using the Net_SMTP package:: + + require 'Net/SMTP.php'; + + $host = 'mail.example.com'; + $from = 'user@example.com'; + $rcpt = array('recipient1@example.com', 'recipient2@example.com'); + $subj = "Subject: Test Message\n"; + $body = "Body Line 1\nBody Line 2"; + + /* Create a new Net_SMTP object. */ + if (! ($smtp = new Net_SMTP($host))) { + die("Unable to instantiate Net_SMTP object\n"); + } + + /* Connect to the SMTP server. */ + if (PEAR::isError($e = $smtp->connect())) { + die($e->getMessage() . "\n"); + } + + /* Send the 'MAIL FROM:' SMTP command. */ + if (PEAR::isError($smtp->mailFrom($from))) { + die("Unable to set sender to <$from>\n"); + } + + /* Address the message to each of the recipients. */ + foreach ($rcpt as $to) { + if (PEAR::isError($res = $smtp->rcptTo($to))) { + die("Unable to add recipient <$to>: " . $res->getMessage() . "\n"); + } + } + + /* Set the body of the message. */ + if (PEAR::isError($smtp->data($subj . "\r\n" . $body))) { + die("Unable to send data\n"); + } + + /* Disconnect from the SMTP server. */ + $smtp->disconnect(); + +.. _PEAR_Error: http://pear.php.net/manual/en/core.pear.pear-error.php +.. _Net_Socket: http://pear.php.net/package/Net_Socket +.. _Auth_SASL: http://pear.php.net/package/Auth_SASL + +.. vim: tabstop=4 shiftwidth=4 softtabstop=4 expandtab textwidth=78 ft=rst: diff --git a/web/admin/dist/attendance.js b/web/admin/dist/attendance.js new file mode 100644 index 00000000..32dc1d21 --- /dev/null +++ b/web/admin/dist/attendance.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,s){if(!a[n]){if(!t[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;nHH:mm"):3===a?"0000-00-00 00:00:00"===t||""===t||void 0===t||null==t?"":Date.parse(t).toString("MMM d HH:mm"):4===a?null!=t&&t.length>10?t.substring(0,10)+"..":t:void 0}},{key:"save",value:function(){var e=new r.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters(),a=this.doCustomValidation(t);if(null==a){var l=$("#"+this.getTableName()+"_submit #id").val();null!=l&&void 0!==l&&""!==l&&(t.id=l);var i=JSON.stringify(t),n=[];n.callBackData=[],n.callBackSuccess="saveSuccessCallback",n.callBackFail="saveFailCallback",this.customAction("savePunch","admin=attendance",i,n)}else{var s=$("#"+this.getTableName()+"Form .label");s.html(a),s.show()}}}},{key:"saveSuccessCallback",value:function(e){this.get(e)}},{key:"saveFailCallback",value:function(e){this.showMessage("Error saving attendance entry",e)}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}},{key:"showPunchImages",value:function(e){var t=JSON.stringify({id:e}),a=[];a.callBackData=[],a.callBackSuccess="getImagesSuccessCallback",a.callBackFail="getImagesFailCallback",this.customAction("getImages","admin=attendance",t,a)}},{key:"getImagesSuccessCallback",value:function(e){if($("#attendancePhotoModel").modal("show"),$("#attendnaceCanvasEmp").html(e.employee_Name),e.in_time&&$("#attendnaceCanvasPunchInTime").html(Date.parse(e.in_time).toString("yyyy MMM d HH:mm")),e.image_in){var t=document.getElementById("attendnaceCanvasIn").getContext("2d"),a=new Image;a.onload=function(){t.drawImage(a,0,0)},a.src=e.image_in}if(e.out_time&&$("#attendnaceCanvasPunchOutTime").html(Date.parse(e.out_time).toString("yyyy MMM d HH:mm")),e.image_out){var l=document.getElementById("attendnaceCanvasOut").getContext("2d"),i=new Image;i.onload=function(){l.drawImage(i,0,0)},i.src=e.image_out}}},{key:"getImagesFailCallback",value:function(e){this.showMessage("Error",e)}},{key:"getActionButtonsHtml",value:function(e,t){var a=void 0;return a=(a=1===this.photoAttendance?'
_edit__delete__photo_
':'
_edit__delete_
').replace("_photo_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}}]),t}(),d=function(e){function t(){return s(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,i.default),l(t,[{key:"getDataMapping",value:function(){return["id","employee","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Clocked In Status"}]}},{key:"getFormFields",value:function(){return[]}},{key:"getFilters",value:function(){return[["employee",{label:"Employee",type:"select2","allow-null":!1,"remote-source":["Employee","id","first_name+last_name"]}]]}},{key:"getActionButtonsHtml",value:function(e,t){var a='
';return a=a.replace(/_BASE_/g,this.baseUrl),"Not Clocked In"==t[2]?a=a.replace(/_COLOR_/g,"gray"):"Clocked Out"==t[2]?a=a.replace(/_COLOR_/g,"yellow"):"Clocked In"==t[2]&&(a=a.replace(/_COLOR_/g,"green")),a}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}();t.exports={AttendanceAdapter:c,AttendanceStatusAdapter:d}},{"../../../api/AdapterBase":4,"../../../api/FormValidation":5}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
'+e+"
"),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
'}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l",l.parent=null;break}r[n.id]=1,i=n}}return""===t||(this.showMessage("Company Structure is having a cyclic dependency","We found a cyclic dependency due to following reasons:
    "+t),!1)}},{key:"getHelpLink",value:function(){return"https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html"}}]),t}();t.exports={CompanyStructureAdapter:c,CompanyGraphAdapter:d}},{"../../../api/AdapterBase":4}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l
    #_name_# #_delete_##_edit_#
    Header Title: #_title_#
    Type: #_type_#
    ',validation:"none","custom-validate-function":function(e){var t={};return t.params=e,t.valid=!0,"Reference"===e.type&&("NULL"===e.dependOn?(t.message="If the type is Reference this field should referring another table",t.valid=!1):null!==dependOnField&&void 0!==dependOnField||(t.message="If the type is Reference then 'Depends On Field' can not be empty",t.valid=!1)),t}}]]}}]),t}(),d=function(e){function t(){return s(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,n.default),i(t,[{key:"getDataMapping",value:function(){return["id","name","data_import_definition","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Data Import Definition"},{sTitle:"Status"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["data_import_definition",{label:"Data Import Definitions",type:"select","remote-source":["DataImport","id","name"]}],["file",{label:"File to Import",type:"fileupload",validation:"",filetypes:"csv,txt"}],["details",{label:"Last Export Result",type:"textarea",validation:"none"}]]}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__process__clone__delete_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_",""),a=(a=(a=(a="Not Processed"===t[3]?a.replace("_process_",''):a.replace("_process_","")).replace(/_id_/g,e)).replace(/_status_/g,t[6])).replace(/_BASE_/g,this.baseUrl)}},{key:"process",value:function(e){var t={id:e},a=JSON.stringify(t),l=[];l.callBackData=[],l.callBackSuccess="processSuccessCallBack",l.callBackFail="processFailCallBack",this.customAction("processDataFile","admin=data",a,l)}},{key:"processSuccessCallBack",value:function(e){this.showMessage("Success","File imported successfully.")}},{key:"processFailCallBack",value:function(e){this.showMessage("Error","File import unsuccessful. Result:"+e)}}]),t}();t.exports={DataImportAdapter:c,DataImportFileAdapter:d}},{"../../../api/AdapterBase":4}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l'+this.gt("Skills")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    '+nl2br(e[3])+"

    ")}}]),t}(),c=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","education_id","institute","date_start","date_end"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Qualification"},{sTitle:"Institute"},{sTitle:"Start Date"},{sTitle:"Completed On"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["education_id",{label:"Qualification",type:"select2","allow-null":!1,"remote-source":["Education","id","name"]}],["institute",{label:"Institute",type:"text",validation:""}],["date_start",{label:"Start Date",type:"date",validation:"none"}],["date_end",{label:"Completed On",type:"date",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Education")}},{key:"getSubItemHtml",value:function(e,t,l){var a="";try{a=Date.parse(e[4]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}var i="";try{i=Date.parse(e[5]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}return $('
    '+e[2]+t+l+'

    Start: '+a+'

    Completed: '+i+'

    Institute: '+e[3]+"

    ")}}]),t}(),p=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","certification_id","institute","date_start","date_end"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Certification"},{sTitle:"Institute"},{sTitle:"Granted On"},{sTitle:"Valid Thru"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["certification_id",{label:"Certification",type:"select2","allow-null":!1,"remote-source":["Certification","id","name"]}],["institute",{label:"Institute",type:"text",validation:""}],["date_start",{label:"Granted On",type:"date",validation:"none"}],["date_end",{label:"Valid Thru",type:"date",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Certifications")}},{key:"getSubItemHtml",value:function(e,t,l){var a="";try{a=Date.parse(e[4]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}var i="";try{i=Date.parse(e[5]).toString("MMM d, yyyy")}catch(e){console.log("Error:"+e.message)}return $('
    '+e[2]+t+l+'

    Granted On: '+a+'

    Valid Thru: '+i+'

    Institute: '+e[3]+"

    ")}}]),t}(),m=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","language_id","reading","speaking","writing","understanding"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Language"},{sTitle:"Reading"},{sTitle:"Speaking"},{sTitle:"Writing"},{sTitle:"Understanding"}]}},{key:"getFormFields",value:function(){var e=[["Elementary Proficiency","Elementary Proficiency"],["Limited Working Proficiency","Limited Working Proficiency"],["Professional Working Proficiency","Professional Working Proficiency"],["Full Professional Proficiency","Full Professional Proficiency"],["Native or Bilingual Proficiency","Native or Bilingual Proficiency"]];return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["language_id",{label:"Language",type:"select2","allow-null":!1,"remote-source":["Language","id","name"]}],["reading",{label:"Reading",type:"select",source:e}],["speaking",{label:"Speaking",type:"select",source:e}],["writing",{label:"Writing",type:"select",source:e}],["understanding",{label:"Understanding",type:"select",source:e}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Languages")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    Reading: '+e[3]+'

    Speaking: '+e[4]+'

    Writing: '+e[5]+'

    Understanding: '+e[6]+"

    ")}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}(),h=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","name","relationship","dob","id_number"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Name"},{sTitle:"Relationship"},{sTitle:"Date of Birth"},{sTitle:"Id Number"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["relationship",{label:"Relationship",type:"select",source:[["Child","Child"],["Spouse","Spouse"],["Parent","Parent"],["Other","Other"]]}],["dob",{label:"Date of Birth",type:"date",validation:""}],["id_number",{label:"Id Number",type:"text",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Dependents")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    Relationship: '+e[3]+'

    Name: '+e[2]+"

    ")}}]),t}(),f=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","name","relationship","home_phone","work_phone","mobile_phone"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Name"},{sTitle:"Relationship"},{sTitle:"Home Phone"},{sTitle:"Work Phone"},{sTitle:"Mobile Phone"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["relationship",{label:"Relationship",type:"text",validation:"none"}],["home_phone",{label:"Home Phone",type:"text",validation:"none"}],["work_phone",{label:"Work Phone",type:"text",validation:"none"}],["mobile_phone",{label:"Mobile Phone",type:"text",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Emergency Contacts")}},{key:"getSubItemHtml",value:function(e,t,l){return $('
    '+e[2]+t+l+'

    Relationship: '+e[3]+'

    Name: '+e[2]+'

    Home Phone: '+e[4]+'

    Mobile Phone: '+e[6]+"

    ")}}]),t}(),y=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,o.default),a(t,[{key:"getDataMapping",value:function(){return["id","employee","document","details","date_added","valid_until","status","attachment"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Document"},{sTitle:"Details"},{sTitle:"Date Added"},{sTitle:"Status"},{sTitle:"Attachment",bVisible:!1}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"hidden"}],["document",{label:"Document",type:"select2","remote-source":["Document","id","name"]}],["date_added",{label:"Date Added",type:"date",validation:""}],["valid_until",{label:"Valid Until",type:"date",validation:"none"}],["status",{label:"Status",type:"select",source:[["Active","Active"],["Inactive","Inactive"],["Draft","Draft"]]}],["details",{label:"Details",type:"textarea",validation:"none"}],["attachment",{label:"Attachment",type:"fileupload",validation:"none"}]]}},{key:"forceInjectValuesBeforeSave",value:function(e){return e.employee=this.parent.currentId,e}},{key:"getSubHeaderTitle",value:function(){return''+this.gt("Documents")}},{key:"getSubItemHtml",value:function(e,t,l){var a="";try{a=Date.parse(e[5]).toString("MMM d, yyyy")}catch(e){console.log(e.message)}var i='';return $('
    '+e[2]+i+t+l+'

    '+nl2br(e[3])+'

    Expire On: '+a+"

    ")}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}(),b=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,i.default),a(t,[{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}(),v=function(e){function t(e,l,a,i){s(this,t);var o=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,l,a,i));return o.fieldNameMap={},o.hiddenFields={},o.tableFields={},o.formOnlyFields={},o}return u(t,b),a(t,[{key:"setFieldNameMap",value:function(e){for(var t=void 0,l=0;l'.replace("_img_",t)}return t}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"getTableFields",value:function(){return["id","image","employee_id","first_name","last_name","mobile_phone","department","gender","supervisor"]}},{key:"getDataMapping",value:function(){for(var e=this.getTableFields(),t=[],l=0;l
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ',validation:"none","sort-function":function(e,t){return Date.parse(e.date).getTime()";return l=(l=l.replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"getHelpLink",value:function(){return"https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html"}},{key:"saveSuccessItemCallback",value:function(e){this.lastSavedEmployee=e,null===this.currentId&&$("#createUserModel").modal("show")}},{key:"closeCreateUser",value:function(){$("#createUserModel").modal("hide")}},{key:"createUser",value:function(){var e={};e.employee=this.lastSavedEmployee.id,e.user_level="Employee",e.email=this.lastSavedEmployee.work_email,e.username=this.lastSavedEmployee.work_email.split("@")[0],top.location.href=this.getCustomUrl("?g=admin&n=users&m=admin_Admin&action=new&object="+Base64.encodeURI(JSON.stringify(e)))}},{key:"deleteEmployee",value:function(e){if(confirm("Are you sure you want to archive this employee? Data for this employee will be saved to an archive table. But you will not be able to covert the archived employee data into a normal employee.")){var t=[];t.callBackData=[],t.callBackSuccess="deleteEmployeeSuccessCallback",t.callBackFail="deleteEmployeeFailCallback",this.customAction("deleteEmployee","admin=employees",JSON.stringify({id:e}),t)}}},{key:"deleteEmployeeSuccessCallback",value:function(e){this.showMessage("Delete Success","Employee deleted. You can find archived information for this employee in Archived Employees tab"),this.get([])}},{key:"deleteEmployeeFailCallback",value:function(e){this.showMessage("Error occurred while deleting Employee",e)}},{key:"terminateEmployee",value:function(e){if(confirm("Are you sure you want to terminate this employee contract? You will still be able to access all details of this employee.")){var t={};t.id=e;var l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="terminateEmployeeSuccessCallback",a.callBackFail="terminateEmployeeFailCallback",this.customAction("terminateEmployee","admin=employees",l,a)}}},{key:"terminateEmployeeSuccessCallback",value:function(e){this.showMessage("Success","Employee contract terminated. You can find terminated employee information under Terminated Employees menu."),this.get([])}},{key:"terminateEmployeeFailCallback",value:function(e){this.showMessage("Error occured while terminating Employee",e)}},{key:"activateEmployee",value:function(e){if(confirm("Are you sure you want to re-activate this employee contract?")){var t={};t.id=e;var l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="activateEmployeeSuccessCallback",a.callBackFail="activateEmployeeFailCallback",this.customAction("activateEmployee","admin=employees",l,a)}}},{key:"activateEmployeeSuccessCallback",value:function(e){this.showMessage("Success","Employee contract re-activated."),this.get([])}},{key:"activateEmployeeFailCallback",value:function(e){this.showMessage("Error occurred while activating Employee",e)}},{key:"view",value:function(e){this.currentId=e;var t={id:e,map:JSON.stringify(this.getSourceMapping())},l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="renderEmployee",a.callBackFail="viewFailCallBack",this.customAction("get","modules=employees",l,a)}},{key:"viewFailCallBack",value:function(e){this.showMessage("Error","Error Occured while retriving candidate")}},{key:"renderEmployee",value:function(e){var t=void 0,l=this.getFormFields();e[1],e[1],e[2];e=e[0],this.currentEmployee=e;for(var a=this.getCustomTemplate("myDetails.html"),i=0;i";if($("#"+this.getTableName()+" #subordinates").html(n),$("#"+this.getTableName()+" #name").html(e.first_name+" "+e.last_name),this.currentUserId=e.id,$("#"+this.getTableName()+" #profile_image_"+e.id).attr("src",e.image),void 0!==e.customFields&&null!==e.customFields&&Object.keys(e.customFields).length>0){var r=void 0;for(var u in e.customFields){e.customFields[u][1]||(e.customFields[u][1]=this.gt("Other Details"));var b=e.customFields[u][1].toLocaleLowerCase();if(b=b.replace(" ","_"),$("#cont_"+b).length<=0){var v='

    #_section.name_#

    ';v=(v=v.replace("#_section_#",b)).replace("#_section.name_#",e.customFields[u][1]),$("#customFieldsCont").append($(v))}r=(r='
    ').replace("#_label_#",u),r="fileupload"===e.customFields[u][2]?r.replace("#_value_#",""):r.replace("#_value_#",e.customFields[u][0]),$("#cont_"+b).append($(r))}}else $("#customFieldsCont").remove();for(var g in this.cancel(),this.isModuleInstalled("admin","documents")||$("#tabDocuments").remove(),window.modJs=this,modJs.subModJsList=[],modJs.subModJsList.tabEmployeeSkillSubTab=new d("EmployeeSkill","EmployeeSkillSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeSkillSubTab.parent=this,modJs.subModJsList.tabEmployeeEducationSubTab=new c("EmployeeEducation","EmployeeEducationSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeEducationSubTab.parent=this,modJs.subModJsList.tabEmployeeCertificationSubTab=new p("EmployeeCertification","EmployeeCertificationSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeCertificationSubTab.parent=this,modJs.subModJsList.tabEmployeeLanguageSubTab=new m("EmployeeLanguage","EmployeeLanguageSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeLanguageSubTab.parent=this,modJs.subModJsList.tabEmployeeDependentSubTab=new h("EmployeeDependent","EmployeeDependentSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeDependentSubTab.parent=this,modJs.subModJsList.tabEmployeeEmergencyContactSubTab=new f("EmergencyContact","EmployeeEmergencyContactSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.parent=this,this.isModuleInstalled("admin","documents")&&(modJs.subModJsList.tabEmployeeDocumentSubTab=new y("EmployeeDocument","EmployeeDocumentSubTab",{employee:e.id}),modJs.subModJsList.tabEmployeeDocumentSubTab.parent=this),modJs.subModJsList)modJs.subModJsList.hasOwnProperty(g)&&(modJs.subModJsList[g].setTranslationsSubModules(this.translations),modJs.subModJsList[g].setPermissions(this.permissions),modJs.subModJsList[g].setFieldTemplates(this.fieldTemplates),modJs.subModJsList[g].setTemplates(this.templates),modJs.subModJsList[g].setCustomTemplates(this.customTemplates),modJs.subModJsList[g].setEmailTemplates(this.emailTemplates),modJs.subModJsList[g].setUser(this.user),modJs.subModJsList[g].initFieldMasterData(),modJs.subModJsList[g].setBaseUrl(this.baseUrl),modJs.subModJsList[g].setCurrentProfile(this.currentProfile),modJs.subModJsList[g].setInstanceId(this.instanceId),modJs.subModJsList[g].setGoogleAnalytics(ga),modJs.subModJsList[g].setNoJSONRequests(this.noJSONRequests));modJs.subModJsList.tabEmployeeSkillSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeSkillSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeSkillSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeSkillSubTab.get([]),modJs.subModJsList.tabEmployeeEducationSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeEducationSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeEducationSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeEducationSubTab.get([]),modJs.subModJsList.tabEmployeeCertificationSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeCertificationSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeCertificationSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeCertificationSubTab.get([]),modJs.subModJsList.tabEmployeeLanguageSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeLanguageSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeLanguageSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeLanguageSubTab.get([]),modJs.subModJsList.tabEmployeeDependentSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeDependentSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeDependentSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeDependentSubTab.get([]),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeEmergencyContactSubTab.get([]),this.isModuleInstalled("admin","documents")&&(modJs.subModJsList.tabEmployeeDocumentSubTab.setShowFormOnPopup(!0),modJs.subModJsList.tabEmployeeDocumentSubTab.setShowAddNew(!1),modJs.subModJsList.tabEmployeeDocumentSubTab.setShowCancel(!1),modJs.subModJsList.tabEmployeeDocumentSubTab.get([])),$("#subModTab a").off().on("click",function(e){e.preventDefault(),$(this).tab("show")})}},{key:"deleteProfileImage",value:function(e){var t={id:e},l=JSON.stringify(t),a=[];a.callBackData=[],a.callBackSuccess="modEmployeeDeleteProfileImageCallBack",a.callBackFail="modEmployeeDeleteProfileImageCallBack",this.customAction("deleteProfileImage","modules=employees",l,a)}},{key:"modEmployeeDeleteProfileImageCallBack",value:function(e){}}]),t}(),g=function(e){function t(){return s(this,t),r(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,v),a(t,[{key:"getDataMapping",value:function(){return["id","image","employee_id","first_name","last_name","mobile_phone","department","gender","supervisor"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID"},{sTitle:"",bSortable:!1},{sTitle:"Employee Number"},{sTitle:"First Name"},{sTitle:"Last Name"},{sTitle:"Mobile"},{sTitle:"Department"},{sTitle:"Gender"},{sTitle:"Supervisor"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden",validation:""}],["employee_id",{label:"Employee Number",type:"text",validation:""}],["first_name",{label:"First Name",type:"text",validation:""}],["middle_name",{label:"Middle Name",type:"text",validation:"none"}],["last_name",{label:"Last Name",type:"text",validation:""}],["nationality",{label:"Nationality",type:"select2","remote-source":["Nationality","id","name"]}],["birthday",{label:"Date of Birth",type:"date",validation:""}],["gender",{label:"Gender",type:"select",source:[["Male","Male"],["Female","Female"]]}],["marital_status",{label:"Marital Status",type:"select",source:[["Married","Married"],["Single","Single"],["Divorced","Divorced"],["Widowed","Widowed"],["Other","Other"]]}],["ssn_num",{label:"SSN/NRIC",type:"text",validation:"none"}],["nic_num",{label:"NIC",type:"text",validation:"none"}],["other_id",{label:"Other ID",type:"text",validation:"none"}],["driving_license",{label:"Driving License No",type:"text",validation:"none"}],["employment_status",{label:"Employment Status",type:"select2","remote-source":["EmploymentStatus","id","name"]}],["job_title",{label:"Job Title",type:"select2","remote-source":["JobTitle","id","name"]}],["pay_grade",{label:"Pay Grade",type:"select2","allow-null":!0,"remote-source":["PayGrade","id","name"]}],["work_station_id",{label:"Work Station Id",type:"text",validation:"none"}],["address1",{label:"Address Line 1",type:"text",validation:"none"}],["address2",{label:"Address Line 2",type:"text",validation:"none"}],["city",{label:"City",type:"text",validation:"none"}],["country",{label:"Country",type:"select2","remote-source":["Country","code","name"]}],["province",{label:"Province",type:"select2","allow-null":!0,"remote-source":["Province","id","name"]}],["postal_code",{label:"Postal/Zip Code",type:"text",validation:"none"}],["home_phone",{label:"Home Phone",type:"text",validation:"none"}],["mobile_phone",{label:"Mobile Phone",type:"text",validation:"none"}],["work_phone",{label:"Work Phone",type:"text",validation:"none"}],["work_email",{label:"Work Email",type:"text",validation:"emailOrEmpty"}],["private_email",{label:"Private Email",type:"text",validation:"emailOrEmpty"}],["joined_date",{label:"Joined Date",type:"date",validation:""}],["confirmation_date",{label:"Confirmation Date",type:"date",validation:"none"}],["termination_date",{label:"Termination Date",type:"date",validation:"none"}],["department",{label:"Department",type:"select2","remote-source":["CompanyStructure","id","title"]}],["supervisor",{label:"Supervisor",type:"select2","allow-null":!0,"remote-source":["Employee","id","first_name+last_name"]}],["notes",{label:"Notes",type:"datagroup",form:[["note",{label:"Note",type:"textarea",validation:""}]],html:'
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ',validation:"none","sort-function":function(e,t){return Date.parse(e.date).getTime()';return l=(l=(l=l.replace(/_id_/g,e)).replace(/_attachment_/g,t[6])).replace(/_BASE_/g,this.baseUrl)}},{key:"isSubProfileTable",value:function(){return"Admin"!==this.user.user_level}}]),t}();t.exports={EmployeeAdapter:v,TerminatedEmployeeAdapter:g,ArchivedEmployeeAdapter:_,EmployeeSkillAdapter:k,EmployeeEducationAdapter:S,EmployeeCertificationAdapter:E,EmployeeLanguageAdapter:w,EmployeeDependentAdapter:T,EmergencyContactAdapter:D,EmployeeImmigrationAdapter:F,EmployeeSubSkillsAdapter:d,EmployeeSubEducationAdapter:c,EmployeeSubCertificationAdapter:p,EmployeeSubLanguageAdapter:m,EmployeeSubDependentAdapter:h,EmployeeSubEmergencyContactAdapter:f,EmployeeSubDocumentAdapter:y,EmployeeDocumentAdapter:M}},{"../../../api/AdapterBase":4,"../../../api/SubAdapterBase":7}],3:[function(e,t,l){"use strict";Object.defineProperty(l,"__esModule",{value:!0});var a=function(){function e(e,t){for(var l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var l=localStorage.getItem(e);return void 0!==l&&null!=l&&""!==l?void 0===(t=JSON.parse(l))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var l=JSON.stringify(t);return localStorage.setItem(e,l),l}}]),e}();l.default=i},{}],4:[function(e,t,l){"use strict";Object.defineProperty(l,"__esModule",{value:!0});var a=function(){function e(e,t){for(var l=0;l0}},o=function(){function e(t,l,a){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=l,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,a),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return a(e,[{key:"clearError",value:function(e,t){var l=e.attr("id");$("#"+this.formId+" #field_"+l).removeClass("error"),$("#"+this.formId+" #help_"+l).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var l=e.attr("id"),a=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+l).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+l).html(i):void 0===a||null==a||""===a?$("#"+this.formId+" #help_err_"+l).html("Required"):"float"===a||"number"===a?$("#"+this.formId+" #help_err_"+l).html("Number required"):"email"===a?$("#"+this.formId+" #help_err_"+l).html("Email required"):$("#"+this.formId+" #help_err_"+l).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var l=function(e){var l=null,a=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+a+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),o=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(o,t.inputTypes)>=0){if(e.hasClass("uploadInput"))l=e.attr("val");else if("radio"===o||"checkbox"===o)l=$("input[name='"+a+"']:checked").val();else if(e.hasClass("select2Field"))l=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");l=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var l in t)t[l].sTitle=this.gt(t[l].sTitle);var a=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(l)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=l?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){l.apply(o,a),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,l,a,i){var o=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=l?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){l.apply(o,a),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var l=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(l.checkValues()){var a=l.getFormParameters();a=this.forceInjectValuesBeforeSave(a);var i=this.doCustomValidation(a);if(null==i){this.csrfRequired&&(a.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var o=$("#"+this.getTableName()+"_submit #id").val();null!=o&&void 0!==o&&""!==o&&(a.id=o),a=this.makeEmptyDateFieldsNull(a),this.add(a,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var l in t)t.hasOwnProperty(l)&&"NULL"===t[l]&&delete t[l];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",l=void 0,a=void 0,i=void 0,o=void 0,n=void 0,s=void 0,r=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,r)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])l=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[l[0]+"_"+l[1]+"_"+l[2]][e[u]];else if(a=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');r.attr("id",s),r.html(t),r.find(".datefield").datepicker({viewMode:2}),r.find(".timefield").datetimepicker({language:"en",pickDate:!1}),r.find(".datetimefield").datetimepicker({language:"en"}),r.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+r.attr("id")+" .tinymce",height:"400"}),r.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),r.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),r.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),l=t.find(".select2-choices").height();t.height(parseInt(l,10))})}),this.showDomElement("Edit",r,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var l=this.templates.formTemplate,a="",i=this.getFormFields(),o=0;o')).attr("id",u):r=$("#"+this.getTableName()+"Form"),r.html(l),r.find(".datefield").datepicker({viewMode:2}),r.find(".timefield").datetimepicker({language:"en",pickDate:!1}),r.find(".datetimefield").datetimepicker({language:"en"}),r.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+r.attr("id")+" .tinymce",height:"400"}),r.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),r.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),r.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),l=t.find(".select2-choices").height();t.height(parseInt(l,10))})}),r.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),a=a.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(a=a.replace("#_renderFunction_#",t[1].render(i))),(o=$(a)).attr("fieldId",t[0]+"_div"),r.append(o)}return r}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var l=this.templates.datagroupTemplate,a="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var o=0;o');s.attr("id",n),s.html(l),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),l=t.find(".select2-choices").height();t.height(parseInt(l,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var l=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(l.checkValues()){var a=l.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[a])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;a=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var o=JSON.parse(i);a.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(o),o.push(a),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&o.sort(e[1]["sort-function"]),i=JSON.stringify(o);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var l="";try{for(var a=e.split(" "),i=0,o=0;ot?(l+=a[o]+"
    ",i=0):l+=a[o]+" "}catch(e){}return l}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var l=$(e.target);if(!/html|body/i.test(l.offsetParent()[0].tagName)){var a=e.pageY-l.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:a+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],l=void 0,a=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var o=JSON.parse(i);a.each(function(){for(var e in l=$(this).attr("id"),o)if(o[e].id===l){t.push(o[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,l=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(l.checkValues()){var a=l.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[a]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;a=i.params}if(this.doCustomFilterValidation(a)){var o=$("#"+e[0]).val();""===o&&(o="[]");for(var s=JSON.parse(o),r={},u=-1,d=[],c=0;c=t&&(t=parseInt(l,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),l=$("#"+t).val(),a=JSON.parse(l),i=[],o=0;o")}catch(e){}if(void 0!==l[i][1].formatter&&l[i][1].formatter&&$.isFunction(l[i][1].formatter))try{a=l[i][1].formatter(a)}catch(e){}$(t+" #"+l[i][0]).html(a)}else if("fileupload"===l[i][1].type)null!=e[l[i][0]]&&void 0!==e[l[i][0]]&&""!==e[l[i][0]]&&($(t+" #"+l[i][0]).html(e[l[i][0]]),$(t+" #"+l[i][0]).attr("val",e[l[i][0]]),$(t+" #"+l[i][0]).show(),$(t+" #"+l[i][0]+"_download").show(),$(t+" #"+l[i][0]+"_remove").show()),!0===l[i][1].readonly&&$(t+" #"+l[i][0]+"_upload").remove();else if("select"===l[i][1].type)void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]]||(e[l[i][0]]="NULL"),$(t+" #"+l[i][0]).val(e[l[i][0]]);else if("select2"===l[i][1].type)void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]]||(e[l[i][0]]="NULL"),$(t+" #"+l[i][0]).select2("val",e[l[i][0]]);else if("select2multi"===l[i][1].type){void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]]||(e[l[i][0]]="NULL");var u=[];if(void 0!==e[l[i][0]]&&null!=e[l[i][0]]&&""!==e[l[i][0]])try{u=JSON.parse(e[l[i][0]])}catch(e){}$(t+" #"+l[i][0]).select2("val",u);var d=$(t+" #"+l[i][0]).find(".select2-choices").height();$(t+" #"+l[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+l[i][0]).css("min-height",d+"px")}else if("datagroup"===l[i][1].type)try{var c=this.dataGroupToHtml(e[l[i][0]],l[i]);$(t+" #"+l[i][0]).val(e[l[i][0]]),$(t+" #"+l[i][0]+"_div").html(""),$(t+" #"+l[i][0]+"_div").append(c),this.makeDataGroupSortable(l[i],$(t+" #"+l[i][0]+"_div_inner"))}catch(e){}else"signature"===l[i][1].type?""===e[l[i][0]]&&void 0===e[l[i][0]]&&null==e[l[i][0]]||$(t+" #"+l[i][0]).data("signaturePad").fromDataURL(e[l[i][0]]):"simplemde"===l[i][1].type?$(t+" #"+l[i][0]).data("simplemde").value(e[l[i][0]]):$(t+" #"+l[i][0]).val(e[l[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var l=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)l=l.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var a=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];l=l.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[a],e))}}else if("colorpick"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,l=(l=l.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),l=(l=void 0!==e[1].filetypes&&null!=e[1].filetypes?l.replace(/_filetypes_/g,e[1].filetypes):l.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(l=(l=l.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return l=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?l.replace(/_validation_/g,'validation="'+e[1].validation+'"'):l.replace(/_validation_/g,""),l=void 0!==e[1].help&&null!==e[1].help?(l=l.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(l=l.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),l=void 0!==e[1].placeholder&&null!==e[1].placeholder?l.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):l.replace(/_placeholder_/g,""),l=void 0!==e[1].mask&&null!==e[1].mask?l.replace(/_mask_/g,'mask="'+e[1].mask+'"'):l.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var l="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?l+='":l+='');var a=[];for(var i in e)a.push(e[i]);!0===t[1].sort&&a.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var o=0;o_val_';l+=r=(r=r.replace("_id_",n)).replace("_val_",this.gt(s))}return l}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var l="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?l+='":l+='');var a=[];for(var i in e)a.push([i,e[i]]);"true"===t[1].sort&&a.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var o=0;o_val_';l+=r=(r=r.replace("_id_",n)).replace("_val_",this.gt(s))}return l}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var l='
    _edit__delete__clone_
    ';return l=this.showAddNew?l.replace("_clone_",''):l.replace("_clone_",""),l=this.showDelete?l.replace("_delete_",''):l.replace("_delete_",""),l=(l=(l=this.showEdit?l.replace("_edit_",''):l.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,l="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",a="",i=e;i>0;--i)a+=l[Math.round(Math.random()*(l.length-1))];return a+t.getTime()}},{key:"checkFileType",value:function(e,t){var l=document.getElementById(e),a="";return l.value.lastIndexOf(".")>0&&(a=l.value.substring(l.value.lastIndexOf(".")+1,l.value.length)),a=a.toLowerCase(),!(t.split(",").indexOf(a)<0)||(l.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),l=t.toGMTString();return(t-new Date(l.substring(0,l.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var l in e)t+=''.replace("__val__",l).replace("__text__",e[l]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,l=void 0,a=0;a
  • ',s='',r=$('
    '),u=this.getSubHeader();if(r.append(u),0===o.length)r.append(''+this.getNoDataMessage()+"");else for(var d=0;d

    '+this.getSubHeaderTitle()+"

    ")}}]),t}();l.default=s},{"./AdapterBase":4}]},{},[1]); +//# sourceMappingURL=employees.js.map diff --git a/web/admin/dist/fieldnames.js b/web/admin/dist/fieldnames.js new file mode 100644 index 00000000..5ea8dbab --- /dev/null +++ b/web/admin/dist/fieldnames.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,o){if(!a[n]){if(!t[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var d=a[n]={exports:{}};t[n][0].call(d.exports,function(e){return i(t[n][1][e]||e)},d,d.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a
    #_delete_##_edit_##_label_#:#_value_#
    ',validation:"none"}],["display_order",{label:"Priority",type:"text",validation:"number"}],["display_section",{label:"Display Section",type:"text",validation:"none"}]]}},{key:"setTableType",value:function(e){this.tableType=e}},{key:"doCustomValidation",value:function(e){var t;return null!=(t=e.name)&&/^[a-z][a-z0-9._]+$/.test(t)?null:"Invalid name for custom field"}},{key:"forceInjectValuesBeforeSave",value:function(e){var t=[e.name],a=[],l=void 0;if(t.push({}),t[1].label=e.field_label,t[1].type=e.field_type,t[1].validation=e.field_validation,["select","select2","select2multi"].indexOf(e.field_type)>=0){for(var i in l=""===e.field_options||void 0===e.field_options?[]:JSON.parse(e.field_options))a.push([l[i].value,l[i].label]);t[1].source=a}return null!=e.field_validation&&void 0!==e.field_validation||(e.field_validation=""),e.data=JSON.stringify(t),e.type=this.tableType,e}}]),t}();a.default=o},{"./AdapterBase":4}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;lparseFloat(e.max_salary))return"Min Salary should be smaller than Max Salary"}catch(e){}return null}}]),t}(),h=function(e){function t(){return s(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,n.default),i(t,[{key:"getDataMapping",value:function(){return["id","name","description"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID"},{sTitle:"Name"},{sTitle:"Description"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Employment Status",type:"text"}],["description",{label:"Description",type:"textarea",validation:""}]]}}]),t}();t.exports={JobTitleAdapter:c,PayGradeAdapter:d,EmploymentStatusAdapter:h}},{"../../../api/AdapterBase":4}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0?a.replace("_status_",''):a.replace("_status_","")).replace("_logs_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"isSubProfileTable",value:function(){return"Admin"!=this.user.user_level}},{key:"getStatusOptionsData",value:function(e){var t={};return"Approved"==e||("Pending"==e?(t.Approved="Approved",t.Rejected="Rejected"):"Rejected"==e||"Cancelled"==e||"Processing"==e||(t["Cancellation Requested"]="Cancellation Requested",t.Cancelled="Cancelled")),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}();a.default=s},{"./LogViewAdapter":7}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s "+a[r].status_to)).replace(/_note_/g,a[r].note)}""!==i&&(l+=t=t.replace("_days_",i)),this.showMessage("Logs",l),timeUtils.convertToRelativeTime($(".logTime"))}},{key:"getLogsFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting data")}}]),t}();a.default=s},{"./AdapterBase":4}],8:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l')).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"getActionButtonHeader",value:function(){return{sTitle:'',sClass:"center"}}}]),t}(),p=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name","pay_period","department","date_start","date_end","status"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Pay Frequency"},{sTitle:"Department"},{sTitle:"Date Start"},{sTitle:"Date End"},{sTitle:"Status"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text"}],["pay_period",{label:"Pay Frequency",type:"select","remote-source":["PayFrequency","id","name"],sort:"none"}],["deduction_group",{label:"Calculation Group",type:"select","remote-source":["DeductionGroup","id","name"],sort:"none"}],["payslipTemplate",{label:"Payslip Template",type:"select","remote-source":["PayslipTemplate","id","name"]}],["department",{label:"Department",type:"select2","remote-source":["CompanyStructure","id","title"],sort:"none"}],["date_start",{label:"Start Date",type:"date",validation:""}],["date_end",{label:"End Date",type:"date",validation:""}],["columns",{label:"Payroll Columns",type:"select2multi","remote-source":["PayrollColumn","id","name"]}],["status",{label:"Status",type:"select",source:[["Draft","Draft"],["Completed","Completed"]],sort:"none"}]]}},{key:"postRenderForm",value:function(e,t){null!=e&&void 0!==e&&void 0!==e.id&&null!=e.id&&(t.find("#pay_period").attr("disabled","disabled"),t.find("#department").attr("disabled","disabled"))}},{key:"process",value:function(e,t){modJs=modJsList.tabPayrollData,modJs.setCurrentPayroll(e),$("#Payroll").hide(),$("#PayrollData").show(),$("#PayrollDataButtons").show(),"Completed"===t?($(".completeBtnTable").hide(),$(".saveBtnTable").hide()):($(".completeBtnTable").show(),$(".saveBtnTable").show()),modJs.get([])}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__process__clone__delete_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace("_process_",'')).replace(/_id_/g,e)).replace(/_status_/g,t[6])).replace(/_BASE_/g,this.baseUrl)}},{key:"get",value:function(e){$("#PayrollData").hide(),$("#PayrollForm").hide(),$("#PayrollDataButtons").hide(),$("#Payroll").show(),modJsList.tabPayrollData.setCurrentPayroll(null),i(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"get",this).call(this,e)}}]),t}(),h=function(e){function t(e,a,l,i){s(this,t);var n=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,a,l,i));return n.cellDataUpdates={},n.payrollId=null,n}return d(t,o.default),l(t,[{key:"validateCellValue",value:function(e,t,a){return modJs.addCellDataUpdate(e.data("colId"),e.data("rowId"),a),!0}},{key:"setCurrentPayroll",value:function(e){this.payrollId=e}},{key:"addAdditionalRequestData",value:function(e,t){return"updateData"===e?t.payrollId=this.payrollId:"updateAllData"===e?t.payrollId=this.payrollId:"getAllData"===e&&(t.payrollId=this.payrollId),t}},{key:"modifyCSVHeader",value:function(e){return e.unshift(""),e}},{key:"getCSVData",value:function(){for(var e="",t=0;t#_delete_##_edit_#
    #_renderFunction_#
    ',validation:"none",render:function(e){return"Variable:"+e.name}}],["calculation_function",{label:"Function",type:"text",validation:"none"}]]}},{key:"getFilters",value:function(){return[["deduction_group",{label:"Calculation Group",type:"select2","allow-null":!0,"null-label":"Any","remote-source":["DeductionGroup","id","name"]}]]}}]),t}(),m=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!0},{sTitle:"Name"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["columns",{label:"Payroll Columns",type:"select2multi","remote-source":["PayrollColumn","id","name"]}]]}}]),t}(),v=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","employee","pay_frequency","deduction_group","currency"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Employee"},{sTitle:"Pay Frequency"},{sTitle:"Calculation Group"},{sTitle:"Currency"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["employee",{label:"Employee",type:"select2","remote-source":["Employee","id","first_name+last_name"]}],["pay_frequency",{label:"Pay Frequency",type:"select2","remote-source":["PayFrequency","id","name"]}],["currency",{label:"Currency",type:"select2","remote-source":["CurrencyType","id","code"]}],["deduction_group",{label:"Calculation Group",type:"select2","allow-null":!0,"null-label":"None","remote-source":["DeductionGroup","id","name"]}],["deduction_exemptions",{label:"Calculation Exemptions",type:"select2multi","remote-source":["Deduction","id","name"],validation:"none"}],["deduction_allowed",{label:"Calculations Assigned",type:"select2multi","remote-source":["Deduction","id","name"],validation:"none"}]]}},{key:"getFilters",value:function(){return[["employee",{label:"Employee",type:"select2","remote-source":["Employee","id","first_name+last_name"]}]]}}]),t}(),y=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name","deduction_group"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Calculation Group"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["componentType",{label:"Salary Component Type",type:"select2multi","allow-null":!0,"remote-source":["SalaryComponentType","id","name"]}],["component",{label:"Salary Component",type:"select2multi","allow-null":!0,"remote-source":["SalaryComponent","id","name"]}],["payrollColumn",{label:"Payroll Report Column",type:"select2","allow-null":!0,"remote-source":["PayrollColumn","id","name"]}],["rangeAmounts",{label:"Calculation Process",type:"datagroup",form:[["lowerCondition",{label:"Lower Limit Condition",type:"select",source:[["No Lower Limit","No Lower Limit"],["gt","Greater than"],["gte","Greater than or Equal"]]}],["lowerLimit",{label:"Lower Limit",type:"text",validation:"float"}],["upperCondition",{label:"Upper Limit Condition",type:"select",source:[["No Upper Limit","No Upper Limit"],["lt","Less than"],["lte","Less than or Equal"]]}],["upperLimit",{label:"Upper Limit",type:"text",validation:"float"}],["amount",{label:"Value",type:"text",validation:""}]],html:'
    #_delete_##_edit_#
    #_renderFunction_#
    ',validation:"none","custom-validate-function":function(e){var t={valid:!0};return"No Lower Limit"===e.lowerCondition&&(e.lowerLimit=0),"No Upper Limit"===e.upperCondition&&(e.upperLimit=0),t.params=e,t},render:function(e){var t="",a=function(e){var t={gt:">",gte:">=",lt:"<",lte:"<="};return t[e]};return"No Lower Limit"!==e.lowerCondition&&(t+=e.lowerLimit+" "+a(e.lowerCondition)+" "),"No Upper Limit"!==e.upperCondition&&(t+=" and ",t+=a(e.upperCondition)+" "+e.upperLimit+" "),""===t?"Deduction is "+e.amount+" for all ranges":"If salary component "+t+" deduction is "+e.amount}}],["deduction_group",{label:"Calculation Group",type:"select2","allow-null":!0,"null-label":"None","remote-source":["DeductionGroup","id","name"]}]]}}]),t}(),g=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name","description"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"},{sTitle:"Details"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["description",{label:"Details",type:"textarea",validation:"none"}]]}}]),t}(),b=function(e){function t(){return s(this,t),u(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return d(t,n.default),l(t,[{key:"getDataMapping",value:function(){return["id","name"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"}]}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}],["data",{label:"Payslip Fields",type:"datagroup",form:[["type",{label:"Type",type:"select",sort:"none",source:[["Payroll Column","Payroll Column"],["Text","Text"],["Company Name","Company Name"],["Company Logo","Company Logo"],["Separators","Separators"]]}],["payrollColumn",{label:"Payroll Column",type:"select2",sort:"none","allow-null":!0,"null-label":"None","remote-source":["PayrollColumn","id","name"]}],["label",{label:"Label",type:"text",validation:"none"}],["text",{label:"Text",type:"textarea",validation:"none"}],["status",{label:"Status",type:"select",sort:"none",source:[["Show","Show"],["Hide","Hide"]]}]],html:'
    #_delete_##_edit_#
    #_type_# #_label_#
    #_text_#
    ',validation:"none","custom-validate-function":function(e){var t={valid:!0};return"Payroll Column"===e.type?"NULL"===e.payrollColumn?(t.valid=!1,t.message="Please select payroll column"):e.payrollColumn="NULL":"Text"===e.type&&""===e.text&&(t.valid=!1,t.message="Text can not be empty"),t.params=e,t}}]]}}]),t}();t.exports={PaydayAdapter:c,PayrollAdapter:p,PayrollDataAdapter:h,PayrollColumnAdapter:f,PayrollColumnTemplateAdapter:m,PayrollEmployeeAdapter:v,DeductionAdapter:y,DeductionGroupAdapter:g,PayslipTemplateAdapter:b}},{"../../../api/AdapterBase":4,"../../../api/TableEditAdapter":7}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},n=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),n=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(n,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===n||"checkbox"===n)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var o=$("#"+t.formId+" #"+i).select2("data");a=[];for(var r=0;r'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],n=this,o="";o=i?"#plainMessageModel":"#messageModel",$(o).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(o).modal({show:!0}),$(o).on("hidden.bs.modal",function(){a.apply(n,l),$(".modal-backdrop").remove()})):$(o).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var n=this,o="";o=i?"#dataMessageModel":"#messageModel",$(o).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(o).modal({show:!0}),$(o).on("hidden.bs.modal",function(){a.apply(n,l),$(".modal-backdrop").remove()})):$(o).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new o.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var n=$("#"+this.getTableName()+"_submit #id").val();null!=n&&void 0!==n&&""!==n&&(l.id=n),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new o.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,n=void 0,o=void 0,r=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(o="",r=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?o=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":r=o=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])o=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');s.attr("id",r),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),n=0;n')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(o=i[d])&&null!=o&&"string"==typeof o&&(o=o.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",o);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(n=$(l)).attr("fieldId",t[0]+"_div"),s.append(n)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var n=0;n');r.attr("id",o),r.html(a),r.find(".datefield").datepicker({viewMode:2}),r.find(".timefield").datetimepicker({language:"en",pickDate:!1}),r.find(".datetimefield").datetimepicker({language:"en"}),r.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+r.attr("id")+" .tinymce",height:"400"}),r.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),r.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),r.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,r,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new o.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(n),n.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&n.sort(e[1]["sort-function"]),i=JSON.stringify(n);var r=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(r),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,n=0;nt?(a+=l[n]+"
    ",i=0):a+=l[n]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var n=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),n)if(n[e].id===a){t.push(n[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new o.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var n=$("#"+e[0]).val();""===n&&(n="[]");for(var r=JSON.parse(n),s={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],n=0;n")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=s=(s=s.replace("_id_",o)).replace("_val_",this.gt(r))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var n=0;n_val_';a+=s=(s=s.replace("_id_",o)).replace("_val_",this.gt(r))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l
    ';var n=$("#"+e+" .dataTables_paginate .active a").html(),o=0;void 0!==n&&null!=n&&(o=15*parseInt(n,10)-15),$("#"+e).html(i);var r={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t,aoColumns:a,bSort:!1,iDisplayLength:15,iDisplayStart:o},s=this.getCustomTableParams();$.extend(r,s),$("#"+e+" #grid").dataTable(r),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$("#"+e+" #grid").editableTableWidget(),$("#"+e+" #grid .editcell").on("validate",function(e,t){return modJs.validateCellValue($(this),e,t)}),this.afterCreateTable(e)}},{key:"afterCreateTable",value:function(e){}},{key:"addCellDataUpdate",value:function(e,t,a){this.cellDataUpdates[e+"="+t]=[e,t,a]}},{key:"addAdditionalRequestData",value:function(e,t){return t}},{key:"sendCellDataUpdates",value:function(){var e=this.cellDataUpdates;e.rowTable=this.rowTable,e.columnTable=this.columnTable,e.valueTable=this.valueTable,e=this.addAdditionalRequestData("updateData",e);var t=JSON.stringify(e),a=[];a.callBackData=[],a.callBackSuccess="updateDataSuccessCallBack",a.callBackFail="updateDataFailCallBack",this.showLoader(),this.customAction("updateData",this.modulePath,t,a)}},{key:"updateDataSuccessCallBack",value:function(e,t){this.hideLoader(),modJs.cellDataUpdates={},modJs.get()}},{key:"updateDataFailCallBack",value:function(e,t){this.hideLoader()}},{key:"sendAllCellDataUpdates",value:function(){var e=this.cellDataUpdates;e.rowTable=this.rowTable,e.columnTable=this.columnTable,e.valueTable=this.valueTable,e=this.addAdditionalRequestData("updateAllData",e);var t=JSON.stringify(e),a=[];a.callBackData=[],a.callBackSuccess="updateDataAllSuccessCallBack",a.callBackFail="updateDataAllFailCallBack",this.showLoader(),this.customAction("updateAllData",this.modulePath,t,a)}},{key:"updateDataAllSuccessCallBack",value:function(e,t){this.hideLoader(),modJs.cellDataUpdates={},modJs.getAllData(!0)}},{key:"updateDataAllFailCallBack",value:function(e,t){this.hideLoader()}},{key:"showActionButtons",value:function(){return!1}}]),t}();a.default=r},{"./AdapterBase":4}]},{},[1]); +//# sourceMappingURL=payroll.js.map diff --git a/web/admin/dist/permissions.js b/web/admin/dist/permissions.js new file mode 100644 index 00000000..bc769ffa --- /dev/null +++ b/web/admin/dist/permissions.js @@ -0,0 +1,2 @@ +!function(){return function e(t,a,l){function i(n,s){if(!a[n]){if(!t[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);var u=new Error("Cannot find module '"+n+"'");throw u.code="MODULE_NOT_FOUND",u}var c=a[n]={exports:{}};t[n][0].call(c.exports,function(e){return i(t[n][1][e]||e)},c,c.exports,e,t,a,l)}return a[n].exports}for(var r="function"==typeof require&&require,n=0;n0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;dDownload Report ':'Download Report ').replace(/_BASE_/g,this.baseUrl),"PDF"===this.currentReport.output||"JSON"===this.currentReport.output)this.showMessage("Download Report",l);else{if(0===t[1].length)return void this.showMessage("Empty Report","There were no data for selected filters");var i=l+'

    ';$("#tempReportTable").remove(),$("#"+this.table).html(i),$("#"+this.table).show(),$("#"+this.table+"Form").hide();var r=[];for(var n in t[1])r.push({sTitle:t[1][n]});var s={oLanguage:{sLengthMenu:"_MENU_ records per page"},aaData:t[2],aoColumns:r,bSort:!1,iDisplayLength:15,iDisplayStart:0};$("#tempReportTable").dataTable(s),$(".dataTables_paginate ul").addClass("pagination"),$(".dataTables_length").hide(),$(".dataTables_filter input").addClass("form-control"),$(".dataTables_filter input").attr("placeholder","Search"),$(".dataTables_filter label").contents().filter(function(){return 3===this.nodeType}).remove(),$(".tableActionButton").tooltip()}}},{key:"fillForm",value:function(e){for(var t=this.getFormFields(),a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var s=0;s'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,s=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",s=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":s=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var d=0;d');o.attr("id",s),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var d=0;d'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[d])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+d+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');s.attr("id",n),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,s,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var s=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(s),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var s=JSON.parse(r),o={},u=-1,d=[],c=0;c=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var d=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",d+"px"),$(t+" #"+a[i][0]).css("min-height",d+"px")}else if("datagroup"===a[i][1].type)try{var c=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(c),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",n)).replace("_val_",this.gt(s))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0?a.replace("_status_",''):a.replace("_status_","")).replace("_logs_",''),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)).replace(/_cstatus_/g,t[this.getStatusFieldPosition()])}},{key:"isSubProfileTable",value:function(){return"Admin"!=this.user.user_level}},{key:"getStatusOptionsData",value:function(e){var t={};return"Approved"==e||("Pending"==e?(t.Approved="Approved",t.Rejected="Rejected"):"Rejected"==e||"Cancelled"==e||"Processing"==e||(t["Cancellation Requested"]="Cancellation Requested",t.Cancelled="Cancelled")),t}},{key:"getStatusOptions",value:function(e){return this.generateOptions(this.getStatusOptionsData(e))}}]),t}();a.default=o},{"./LogViewAdapter":8}],6:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a
    #_delete_##_edit_##_label_#:#_value_#
    ',validation:"none"}],["display_order",{label:"Priority",type:"text",validation:"number"}],["display_section",{label:"Display Section",type:"text",validation:"none"}]]}},{key:"setTableType",value:function(e){this.tableType=e}},{key:"doCustomValidation",value:function(e){var t;return null!=(t=e.name)&&/^[a-z][a-z0-9._]+$/.test(t)?null:"Invalid name for custom field"}},{key:"forceInjectValuesBeforeSave",value:function(e){var t=[e.name],a=[],l=void 0;if(t.push({}),t[1].label=e.field_label,t[1].type=e.field_type,t[1].validation=e.field_validation,["select","select2","select2multi"].indexOf(e.field_type)>=0){for(var i in l=""===e.field_options||void 0===e.field_options?[]:JSON.parse(e.field_options))a.push([l[i].value,l[i].label]);t[1].source=a}return null!=e.field_validation&&void 0!==e.field_validation||(e.field_validation=""),e.data=JSON.stringify(t),e.type=this.tableType,e}}]),t}();a.default=o},{"./AdapterBase":4}],7:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var n=$("#"+t.formId+" #"+i).select2("data");a=[];for(var o=0;o "+a[r].status_to)).replace(/_note_/g,a[r].note)}""!==i&&(l+=t=t.replace("_days_",i)),this.showMessage("Logs",l),timeUtils.convertToRelativeTime($(".logTime"))}},{key:"getLogsFailCallBack",value:function(e){this.showMessage("Error","Error occured while getting data")}}]),t}();a.default=o},{"./AdapterBase":4}],9:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l,i=function(){function e(e,t){for(var a=0;a'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,n="";n=i?"#plainMessageModel":"#messageModel",$(n).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,n="";n=i?"#dataMessageModel":"#messageModel",$(n).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(n).modal({show:!0}),$(n).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(n).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new n.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new n.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,n=void 0,o=void 0,s=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(n="",o=null,"select"===(i=this.getMetaFieldValues(u,s)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":o=n=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])n=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');s.attr("id",o),s.html(t),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",s,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):s=$("#"+this.getTableName()+"Form"),s.html(a),s.find(".datefield").datepicker({viewMode:2}),s.find(".timefield").datetimepicker({language:"en",pickDate:!1}),s.find(".datetimefield").datetimepicker({language:"en"}),s.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+s.attr("id")+" .tinymce",height:"400"}),s.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),s.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),s.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),s.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(n=i[c])&&null!=n&&"string"==typeof n&&(n=n.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",n);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),s.append(r)}return s}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');o.attr("id",n),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,o,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var o=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(o),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new n.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var o=JSON.parse(r),s={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=s=(s=s.replace("_id_",n)).replace("_val_",this.gt(o))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;l",t+=" You may create a new employee through 'Admin'->'Employees' menu"),t}},{key:"save",value:function(){var e=new i.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters(),a=this.doCustomValidation(t);if(null==a){var l=$("#"+this.getTableName()+"_submit #id").val();if(t.csrf=$("#"+this.getTableName()+"Form").data("csrf"),null!=l&&void 0!==l&&""!==l)t.id=l,this.add(t,[]);else{var r=JSON.stringify(t),s=[];s.callBackData=[],s.callBackSuccess="saveUserSuccessCallBack",s.callBackFail="saveUserFailCallBack",this.customAction("saveUser","admin=users",r,s)}}else this.showMessage("Error Saving User",a)}}},{key:"changePasswordConfirm",value:function(){$("#adminUsersChangePwd_error").hide();var e=$("#adminUsersChangePwd #newpwd").val();if(!(e.length>7))return $("#adminUsersChangePwd_error").html("Password should be longer than 7 characters"),void $("#adminUsersChangePwd_error").show();var t=$("#adminUsersChangePwd #conpwd").val();if(t!==e)return $("#adminUsersChangePwd_error").html("Passwords don't match"),void $("#adminUsersChangePwd_error").show();var a={id:this.currentId,pwd:t},l=JSON.stringify(a),i=[];i.callBackData=[],i.callBackSuccess="changePasswordSuccessCallBack",i.callBackFail="changePasswordFailCallBack",this.customAction("changePassword","admin=users",l,i)}},{key:"closeChangePassword",value:function(){$("#adminUsersModel").modal("hide")}},{key:"changePasswordSuccessCallBack",value:function(e,t){this.closeChangePassword(),this.showMessage("Password Change","Password changed successfully")}},{key:"changePasswordFailCallBack",value:function(e,t){this.closeChangePassword(),this.showMessage("Error",e)}}]),t}(),d=function(e){function t(){return n(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return u(t,r.default),l(t,[{key:"getDataMapping",value:function(){return["id","name"]}},{key:"getHeaders",value:function(){return[{sTitle:"ID",bVisible:!1},{sTitle:"Name"}]}},{key:"postRenderForm",value:function(e,t){t.find("#changePasswordBtn").remove()}},{key:"getFormFields",value:function(){return[["id",{label:"ID",type:"hidden"}],["name",{label:"Name",type:"text",validation:""}]]}}]),t}();t.exports={UserAdapter:c,UserRoleAdapter:d}},{"../../../api/AdapterBase":4,"../../../api/FormValidation":5}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0&&localStorage.removeItem(t)}},{key:"getData",value:function(e){var t=void 0;if("undefined"==typeof Storage)return null;var a=localStorage.getItem(e);return void 0!==a&&null!=a&&""!==a?void 0===(t=JSON.parse(a))||null==t?null:void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status?null:t:null}},{key:"setData",value:function(e,t){if("undefined"==typeof Storage)return null;if(void 0!==t.status&&null!=t.status&&"SUCCESS"!==t.status)return null;var a=JSON.stringify(t);return localStorage.setItem(e,a),a}}]),e}();a.default=i},{}],4:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var l=function(){function e(e,t){for(var a=0;a0}},r=function(){function e(t,a,l){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.tempOptions={},this.formId=t,this.formError=!1,this.formObject=null,this.errorMessages="",this.popupDialog=null,this.validateAll=a,this.errorMap=[],this.settings={thirdPartyPopup:null,LabelErrorClass:!1,ShowPopup:!0},this.settings=jQuery.extend(this.settings,l),this.inputTypes=["text","radio","checkbox","file","password","select-one","select-multi","textarea","fileupload","signature"],this.validator=i}return l(e,[{key:"clearError",value:function(e,t){var a=e.attr("id");$("#"+this.formId+" #field_"+a).removeClass("error"),$("#"+this.formId+" #help_"+a).html("")}},{key:"addError",value:function(e,t){this.formError=!0,null!=e.attr("message")?(this.errorMessages+=e.attr("message")+"\n",this.errorMap[e.attr("name")]=e.attr("message")):this.errorMap[e.attr("name")]="";var a=e.attr("id"),l=e.attr("validation"),i=e.attr("validation");$("#"+this.formId+" #field_"+a).addClass("error"),void 0===i||null==i||""===i?$("#"+this.formId+" #help_err_"+a).html(i):void 0===l||null==l||""===l?$("#"+this.formId+" #help_err_"+a).html("Required"):"float"===l||"number"===l?$("#"+this.formId+" #help_err_"+a).html("Number required"):"email"===l?$("#"+this.formId+" #help_err_"+a).html("Email required"):$("#"+this.formId+" #help_err_"+a).html("Required")}},{key:"showErrors",value:function(){this.formError&&(void 0!==this.settings.thirdPartyPopup&&null!=this.settings.thirdPartyPopup?this.settings.thirdPartyPopup.alert():!0===this.settings.ShowPopup&&(void 0!==this.tempOptions.popupTop&&null!=this.tempOptions.popupTop?this.alert("Errors Found",this.errorMessages,this.tempOptions.popupTop):this.alert("Errors Found",this.errorMessages,-1)))}},{key:"checkValues",value:function(e){this.tempOptions=e;var t=this;this.formError=!1,this.errorMessages="",this.formObject={};var a=function(e){var a=null,l=e.attr("name");!1!==t.settings.LabelErrorClass&&$("label[for='"+l+"']").removeClass(t.settings.LabelErrorClass);var i=e.attr("id"),r=e.attr("type");if(e.hasClass("select2-focusser")||e.hasClass("select2-input"))return!0;if(jQuery.inArray(r,t.inputTypes)>=0){if(e.hasClass("uploadInput"))a=e.attr("val");else if("radio"===r||"checkbox"===r)a=$("input[name='"+l+"']:checked").val();else if(e.hasClass("select2Field"))a=null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")?$("#"+t.formId+" #"+i).select2("data").id:"";else if(e.hasClass("select2Multi"))if(null!=$("#"+t.formId+" #"+i).select2("data")&&void 0!==$("#"+t.formId+" #"+i).select2("data")){var s=$("#"+t.formId+" #"+i).select2("data");a=[];for(var n=0;n'),null!=this.getFilters()&&(""!==e&&(e+="  "),e+='',e+="  ",this.filtersAlreadySet?e+='':e+=''),e=e.replace(/__id__/g,this.getTableName()),""!==(e=""!==this.currentFilterString&&null!=this.currentFilterString?e.replace(/__filterString__/g,this.currentFilterString):e.replace(/__filterString__/g,"Reset Filters"))&&(e='
    '+e+"
    "),e}},{key:"getActionButtonHeader",value:function(){return{sTitle:"",sClass:"center"}}},{key:"getTableHTMLTemplate",value:function(){return'
    '}},{key:"isSortable",value:function(){return!0}},{key:"createTable",value:function(e){if(this.getRemoteTable())this.createTableServer(e);else{var t=this.getHeaders();for(var a in t)t[a].sTitle=this.gt(t[a].sTitle);var l=this.getTableData();if(this.showActionButtons()&&t.push(this.getActionButtonHeader()),this.showActionButtons())for(var i=0;i")),$("#"+e+"ModelLabel").html(t),$("#"+e+"ModelBody").html(""),$("#"+e+"ModelBody").append(a)}},{key:"deleteRow",value:function(e){this.deleteParams.id=e,this.renderModel("delete","Confirm Deletion","Are you sure you want to delete this item ?"),$("#deleteModel").modal("show")}},{key:"showMessage",value:function(e,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r=this,s="";s=i?"#plainMessageModel":"#messageModel",$(s).off(),i?this.renderModel("plainMessage",e,t):this.renderModel("message",e,t),null!=a?($(s).modal({show:!0}),$(s).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(s).modal({backdrop:"static"})}},{key:"showDomElement",value:function(e,t,a,l,i){var r=this,s="";s=i?"#dataMessageModel":"#messageModel",$(s).unbind("hide"),i?this.renderModelFromDom("dataMessage",e,t):this.renderModelFromDom("message",e,t),null!=a?($(s).modal({show:!0}),$(s).on("hidden.bs.modal",function(){a.apply(r,l),$(".modal-backdrop").remove()})):$(s).modal({backdrop:"static"})}},{key:"confirmDelete",value:function(){void 0===this.deleteParams.id&&null==this.deleteParams.id||this.deleteObj(this.deleteParams.id,[]),$("#deleteModel").modal("hide")}},{key:"cancelDelete",value:function(){$("#deleteModel").modal("hide"),this.deleteParams.id=null}},{key:"closeMessage",value:function(){$("#messageModel").modal("hide")}},{key:"cancelYesno",value:function(){$("#yesnoModel").modal("hide")}},{key:"closePlainMessage",value:function(){$("#plainMessageModel").modal("hide"),$("#dataMessageModel").modal("hide")}},{key:"closeDataMessage",value:function(){$("#dataMessageModel").modal("hide")}},{key:"save",value:function(e,t){var a=new s.default(this.getTableName()+"_submit",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();l=this.forceInjectValuesBeforeSave(l);var i=this.doCustomValidation(l);if(null==i){this.csrfRequired&&(l.csrf=$("#"+this.getTableName()+"Form").data("csrf"));var r=$("#"+this.getTableName()+"_submit #id").val();null!=r&&void 0!==r&&""!==r&&(l.id=r),l=this.makeEmptyDateFieldsNull(l),this.add(l,[],e,t)}else $("#"+this.getTableName()+"Form .label").html(i),$("#"+this.getTableName()+"Form .label").show(),this.scrollToTop()}}},{key:"makeEmptyDateFieldsNull",value:function(e){return this.getFormFields().forEach(function(t){"date"!==t[1].type&&"datetime"!==t[1].type||""!==e[t[0]]&&"0000-00-00"!==e[t[0]]&&"0000-00-00 00:00:00"!==e[t[0]]||("none"===t[1].validation?e[t[0]]="NULL":delete e[t[0]])}),e}},{key:"forceInjectValuesBeforeSave",value:function(e){return e}},{key:"doCustomValidation",value:function(e){return null}},{key:"filterQuery",value:function(){var e=new s.default(this.getTableName()+"_filter",!0,{ShowPopup:!1,LabelErrorClass:"error"});if(e.checkValues()){var t=e.getFormParameters();if(this.doCustomFilterValidation(t)){for(var a in t)t.hasOwnProperty(a)&&"NULL"===t[a]&&delete t[a];this.setFilter(t),this.filtersAlreadySet=!0,$("#"+this.getTableName()+"_resetFilters").show(),this.currentFilterString=this.getFilterString(t),this.get([]),this.closePlainMessage()}}}},{key:"getFilterString",value:function(e){var t="",a=void 0,l=void 0,i=void 0,r=void 0,s=void 0,n=void 0,o=this.getFilters();for(var u in null==i&&(i=[]),e)if(e.hasOwnProperty(u)){if(s="",n=null,"select"===(i=this.getMetaFieldValues(u,o)).type||"select2"===i.type){if(void 0!==i["remote-source"]&&null!=i["remote-source"])a=i["remote-source"],"NULL"===e[u]?s=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected":n=s=this.fieldMasterData[a[0]+"_"+a[1]+"_"+a[2]][e[u]];else if(l=i.source[0],"NULL"===e[u])s=void 0!==i["null-label"]&&null!=i["null-label"]?i["null-label"]:"Not Selected";else for(var c=0;c');o.attr("id",n),o.html(t),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.showDomElement("Edit",o,null,null,!0),$(".filterBtn").off(),$(".filterBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.filterQuery()}catch(e){}return!1}),void 0!==this.filter&&null!=this.filter&&""!==this.filter&&this.fillForm(this.filter,"#"+this.getTableName()+"_filter",this.getFilters())}},{key:"preRenderForm",value:function(e){}},{key:"renderForm",value:function(e){var t=[];null!=e&&void 0!==e||(this.currentId=null),this.preRenderForm(e);for(var a=this.templates.formTemplate,l="",i=this.getFormFields(),r=0;r')).attr("id",u):o=$("#"+this.getTableName()+"Form"),o.html(a),o.find(".datefield").datepicker({viewMode:2}),o.find(".timefield").datetimepicker({language:"en",pickDate:!1}),o.find(".datetimefield").datetimepicker({language:"en"}),o.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+o.attr("id")+" .tinymce",height:"400"}),o.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),o.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),o.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),o.find(".signatureField").each(function(){t.push($(this).attr("id"))});for(var c=0;c'),u=0;u
  • ')).replace("#_edit_#",'
  • ')).replace(/#_id_#/g,i.id),i)void 0!==(s=i[c])&&null!=s&&"string"==typeof s&&(s=s.replace(/(?:\r\n|\r|\n)/g,"
    ")),l=l.replace("#_"+c+"_#",s);void 0!==t[1].render&&null!=t[1].render&&(l=l.replace("#_renderFunction_#",t[1].render(i))),(r=$(l)).attr("fieldId",t[0]+"_div"),o.append(r)}return o}},{key:"resetDataGroup",value:function(e){$("#"+e[0]).val(""),$("#"+e[0]+"_div").html("")}},{key:"showDataGroup",value:function(e,t){var a=this.templates.datagroupTemplate,l="",i=e[1].form;void 0!==t&&null!=t&&void 0!==t.id?this.currentDataGroupItemId=t.id:this.currentDataGroupItemId=null;for(var r=0;r');n.attr("id",s),n.html(a),n.find(".datefield").datepicker({viewMode:2}),n.find(".timefield").datetimepicker({language:"en",pickDate:!1}),n.find(".datetimefield").datetimepicker({language:"en"}),n.find(".colorpick").colorpicker(),tinymce.init({selector:"#"+n.attr("id")+" .tinymce",height:"400"}),n.find(".simplemde").each(function(){var e=new SimpleMDE({element:$(this)[0]});$(this).data("simplemde",e)}),n.find(".select2Field").each(function(){$(this).select2().select2("val",$(this).find("option:eq(0)").val())}),n.find(".select2Multi").each(function(){$(this).select2().on("change",function(e){var t=$(this).parents(".row"),a=t.find(".select2-choices").height();t.height(parseInt(a,10))})}),this.currentDataGroupField=e,this.showDomElement("Add "+e[1].label,n,null,null,!0),void 0!==t&&null!=t?this.fillForm(t,"#"+this.getTableName()+"_field_"+e[0],e[1].form):this.setDefaultValues("#"+this.getTableName()+"_field_"+e[0],e[1].form),$(".groupAddBtn").off(),void 0!==t&&null!=t&&void 0!==t.id?$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.editDataGroup()}catch(e){console.log("Error editing data group: "+e.message)}return!1}):$(".groupAddBtn").on("click",function(e){e.preventDefault(),e.stopPropagation();try{modJs.addDataGroup()}catch(e){console.log("Error adding data group: "+e.message)}return!1})}},{key:"addDataGroup",value:function(){var e=this.currentDataGroupField,t=void 0;$("#"+this.getTableName()+"_field_"+e[0]+"_error").html(""),$("#"+this.getTableName()+"_field_"+e[0]+"_error").hide();var a=new s.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){if(!(t=e[1]["custom-validate-function"].apply(this,[l])).valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(t.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=t.params}var i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.id=e[0]+"_"+this.dataGroupGetNextAutoIncrementId(r),r.push(l),void 0!==e[1]["sort-function"]&&null!=e[1]["sort-function"]&&r.sort(e[1]["sort-function"]),i=JSON.stringify(r);var n=this.dataGroupToHtml(i,e);$("#"+e[0]+"_div").html(""),$("#"+e[0]+"_div").append(n),this.makeDataGroupSortable(e,$("#"+e[0]+"_div_inner")),$("#"+e[0]).val(i),this.orderDataGroup(e),this.closeDataMessage(),this.showMessage("Item Added","This change will be effective only when you save the form")}return!0}},{key:"nl2br",value:function(e,t){var a="";try{for(var l=e.split(" "),i=0,r=0;rt?(a+=l[r]+"
    ",i=0):a+=l[r]+" "}catch(e){}return a}},{key:"makeDataGroupSortable",value:function(e,t){t.data("field",e),t.data("firstSort",!0),t.sortable({create:function(){$(this).height($(this).height())},"ui-floating":!1,start:function(e,t){$("#sortable-ul-selector-id").sortable({sort:function(e,t){var a=$(e.target);if(!/html|body/i.test(a.offsetParent()[0].tagName)){var l=e.pageY-a.offsetParent().offset().top-t.helper.outerHeight(!0)/2;t.helper.css({top:l+"px"})}}})},revert:!0,stop:function(){modJs.orderDataGroup($(this).data("field"))},axis:"y",scroll:!1,placeholder:"sortable-placeholder",cursor:"move"})}},{key:"orderDataGroup",value:function(e){var t=[],a=void 0,l=$("#"+e[0]+"_div_inner [fieldid='"+e[0]+"_div']"),i=$("#"+e[0]).val();""===i&&(i="[]");var r=JSON.parse(i);l.each(function(){for(var e in a=$(this).attr("id"),r)if(r[e].id===a){t.push(r[e]);break}}),$("#"+e[0]).val(JSON.stringify(t))}},{key:"editDataGroup",value:function(){var e=this.currentDataGroupField,t=this.currentDataGroupItemId,a=new s.default(this.getTableName()+"_field_"+e[0],!0,{ShowPopup:!1,LabelErrorClass:"error"});if(a.checkValues()){var l=a.getFormParameters();if(void 0!==e[1]["custom-validate-function"]&&null!=e[1]["custom-validate-function"]){var i=e[1]["custom-validate-function"].apply(this,[l]);if(!i.valid)return $("#"+this.getTableName()+"_field_"+e[0]+"_error").html(i.message),$("#"+this.getTableName()+"_field_"+e[0]+"_error").show(),!1;l=i.params}if(this.doCustomFilterValidation(l)){var r=$("#"+e[0]).val();""===r&&(r="[]");for(var n=JSON.parse(r),o={},u=-1,c=[],d=0;d=t&&(t=parseInt(a,10)+1)}return t}},{key:"deleteDataGroupItem",value:function(e){for(var t=e.substring(0,e.lastIndexOf("_")),a=$("#"+t).val(),l=JSON.parse(a),i=[],r=0;r")}catch(e){}if(void 0!==a[i][1].formatter&&a[i][1].formatter&&$.isFunction(a[i][1].formatter))try{l=a[i][1].formatter(l)}catch(e){}$(t+" #"+a[i][0]).html(l)}else if("fileupload"===a[i][1].type)null!=e[a[i][0]]&&void 0!==e[a[i][0]]&&""!==e[a[i][0]]&&($(t+" #"+a[i][0]).html(e[a[i][0]]),$(t+" #"+a[i][0]).attr("val",e[a[i][0]]),$(t+" #"+a[i][0]).show(),$(t+" #"+a[i][0]+"_download").show(),$(t+" #"+a[i][0]+"_remove").show()),!0===a[i][1].readonly&&$(t+" #"+a[i][0]+"_upload").remove();else if("select"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).val(e[a[i][0]]);else if("select2"===a[i][1].type)void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL"),$(t+" #"+a[i][0]).select2("val",e[a[i][0]]);else if("select2multi"===a[i][1].type){void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]]||(e[a[i][0]]="NULL");var u=[];if(void 0!==e[a[i][0]]&&null!=e[a[i][0]]&&""!==e[a[i][0]])try{u=JSON.parse(e[a[i][0]])}catch(e){}$(t+" #"+a[i][0]).select2("val",u);var c=$(t+" #"+a[i][0]).find(".select2-choices").height();$(t+" #"+a[i][0]).find(".controls").css("min-height",c+"px"),$(t+" #"+a[i][0]).css("min-height",c+"px")}else if("datagroup"===a[i][1].type)try{var d=this.dataGroupToHtml(e[a[i][0]],a[i]);$(t+" #"+a[i][0]).val(e[a[i][0]]),$(t+" #"+a[i][0]+"_div").html(""),$(t+" #"+a[i][0]+"_div").append(d),this.makeDataGroupSortable(a[i],$(t+" #"+a[i][0]+"_div_inner"))}catch(e){}else"signature"===a[i][1].type?""===e[a[i][0]]&&void 0===e[a[i][0]]&&null==e[a[i][0]]||$(t+" #"+a[i][0]).data("signaturePad").fromDataURL(e[a[i][0]]):"simplemde"===a[i][1].type?$(t+" #"+a[i][0]).data("simplemde").value(e[a[i][0]]):$(t+" #"+a[i][0]).val(e[a[i][0]])}},{key:"cancel",value:function(){$("#"+this.getTableName()+"Form").hide(),$("#"+this.getTableName()).show()}},{key:"renderFormField",value:function(e){var t=0;if(void 0===this.fieldTemplates[e[1].type]||null==this.fieldTemplates[e[1].type])return"";var a=this.fieldTemplates[e[1].type];if(e[1].label=this.gt(e[1].label),"none"!==e[1].validation&&"emailOrEmpty"!==e[1].validation&&"numberOrEmpty"!==e[1].validation&&"placeholder"!==e[1].type&&e[1].label.indexOf("*")<0){["select","select2"].indexOf(e[1].type)>=0&&!0===e[1]["allow-null"]||(e[1].label=e[1].label+'*')}if("text"===e[1].type||"textarea"===e[1].type||"hidden"===e[1].type||"label"===e[1].type||"placeholder"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("select"===e[1].type||"select2"===e[1].type||"select2multi"===e[1].type){if(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label),void 0!==e[1].source&&null!=e[1].source)a=a.replace("_options_",this.renderFormSelectOptions(e[1].source,e));else if(void 0!==e[1]["remote-source"]&&null!=e[1]["remote-source"]){var l=e[1]["remote-source"][0]+"_"+e[1]["remote-source"][1]+"_"+e[1]["remote-source"][2];a=a.replace("_options_",this.renderFormSelectOptionsRemote(this.fieldMasterData[l],e))}}else if("colorpick"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("date"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("datetime"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("time"===e[1].type)a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);else if("fileupload"===e[1].type){a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label);var i=this.getCurrentProfile();t=null!=i&&void 0!==i?i.id:-1*this.getUser().id,a=(a=a.replace(/_userId_/g,t)).replace(/_group_/g,this.tab),a=(a=void 0!==e[1].filetypes&&null!=e[1].filetypes?a.replace(/_filetypes_/g,e[1].filetypes):a.replace(/_filetypes_/g,"all")).replace(/_rand_/g,this.generateRandom(14))}else"datagroup"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"signature"===e[1].type?a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label):"tinymce"!==e[1].type&&"simplemde"!==e[1].type||(a=(a=a.replace(/_id_/g,e[0])).replace(/_label_/g,e[1].label));return a=void 0!==e[1].validation&&null!=e[1].validation&&""!==e[1].validation?a.replace(/_validation_/g,'validation="'+e[1].validation+'"'):a.replace(/_validation_/g,""),a=void 0!==e[1].help&&null!==e[1].help?(a=a.replace(/_helpline_/g,e[1].help)).replace(/_hidden_class_help_/g,""):(a=a.replace(/_helpline_/g,"")).replace(/_hidden_class_help_/g,"hide"),a=void 0!==e[1].placeholder&&null!==e[1].placeholder?a.replace(/_placeholder_/g,'placeholder="'+e[1].placeholder+'"'):a.replace(/_placeholder_/g,""),a=void 0!==e[1].mask&&null!==e[1].mask?a.replace(/_mask_/g,'mask="'+e[1].mask+'"'):a.replace(/_mask_/g,"")}},{key:"renderFormSelectOptions",value:function(e,t){var a="";null!=t&&void 0!==t&&!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push(e[i]);!0===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",s)).replace("_val_",this.gt(n))}return a}},{key:"renderFormSelectOptionsRemote",value:function(e,t){var a="";!0===t[1]["allow-null"]&&(void 0!==t[1]["null-label"]&&null!=t[1]["null-label"]?a+='":a+='');var l=[];for(var i in e)l.push([i,e[i]]);"true"===t[1].sort&&l.sort(function(e,t){return(e=e[1])<(t=t[1])?-1:e>t?1:0});for(var r=0;r_val_';a+=o=(o=o.replace("_id_",s)).replace("_val_",this.gt(n))}return a}},{key:"setCustomTemplates",value:function(e){this.customTemplates=e}},{key:"setEmailTemplates",value:function(e){this.emailTemplates=e}},{key:"getCustomTemplate",value:function(e){return this.customTemplates[e]}},{key:"setFieldTemplates",value:function(e){this.fieldTemplates=e}},{key:"getMetaFieldForRendering",value:function(e){return""}},{key:"clearDeleteParams",value:function(){this.deleteParams={}}},{key:"getShowAddNew",value:function(){return this.showAddNew}},{key:"getAddNewLabel",value:function(){return"Add New"}},{key:"setShowAddNew",value:function(e){this.showAddNew=e}},{key:"setShowDelete",value:function(e){this.showDelete=e}},{key:"setShowEdit",value:function(e){this.showEdit=e}},{key:"setShowSave",value:function(e){this.showSave=e}},{key:"setShowCancel",value:function(e){this.showCancel=e}},{key:"getCustomTableParams",value:function(){return{}}},{key:"getActionButtons",value:function(e){return modJs.getActionButtonsHtml(e.aData[0],e.aData)}},{key:"getActionButtonsHtml",value:function(e,t){var a='
    _edit__delete__clone_
    ';return a=this.showAddNew?a.replace("_clone_",''):a.replace("_clone_",""),a=this.showDelete?a.replace("_delete_",''):a.replace("_delete_",""),a=(a=(a=this.showEdit?a.replace("_edit_",''):a.replace("_edit_","")).replace(/_id_/g,e)).replace(/_BASE_/g,this.baseUrl)}},{key:"generateRandom",value:function(e){for(var t=new Date,a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",l="",i=e;i>0;--i)l+=a[Math.round(Math.random()*(a.length-1))];return l+t.getTime()}},{key:"checkFileType",value:function(e,t){var a=document.getElementById(e),l="";return a.value.lastIndexOf(".")>0&&(l=a.value.substring(a.value.lastIndexOf(".")+1,a.value.length)),l=l.toLowerCase(),!(t.split(",").indexOf(l)<0)||(a.value="",this.showMessage("File Type Error","Selected file type is not supported"),this.clearFileElement(e),!1)}},{key:"clearFileElement",value:function(e){var t=$("#"+e);t.replaceWith(t=t.val("").clone(!0))}},{key:"fixJSON",value:function(e){return"1"===this.noJSONRequests&&(e=window.btoa(e)),e}},{key:"getClientDate",value:function(e){var t=this.getClientGMTOffset();return e.addMinutes(60*t)}},{key:"getClientGMTOffset",value:function(){var e=new Date,t=new Date(e.getFullYear(),0,1,0,0,0,0),a=t.toGMTString();return(t-new Date(a.substring(0,a.lastIndexOf(" ")-1)))/36e5}},{key:"getHelpLink",value:function(){return null}},{key:"showLoader",value:function(){$("#iceloader").show()}},{key:"hideLoader",value:function(){$("#iceloader").hide()}},{key:"generateOptions",value:function(e){var t="";for(var a in e)t+=''.replace("__val__",a).replace("__text__",e[a]);return t}},{key:"isModuleInstalled",value:function(e,t){return void 0!==modulesInstalled&&null!==modulesInstalled&&1===modulesInstalled[e+"_"+t]}},{key:"setCustomFields",value:function(e){for(var t=void 0,a=void 0,l=0;lHH:mm'); + } if (id === 3) { + if (cell === '0000-00-00 00:00:00' || cell === '' || cell === undefined || cell == null) { + return ''; + } + return Date.parse(cell).toString('MMM d HH:mm'); + } if (id === 4) { + if (cell !== undefined && cell !== null) { + if (cell.length > 10) { + return `${cell.substring(0, 10)}..`; + } + } + return cell; + } + } + + + save() { + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + const params = validator.getFormParameters(); + + const msg = this.doCustomValidation(params); + if (msg == null) { + const id = $(`#${this.getTableName()}_submit #id`).val(); + if (id != null && id !== undefined && id !== '') { + params.id = id; + } + + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'saveSuccessCallback'; + callBackData.callBackFail = 'saveFailCallback'; + + this.customAction('savePunch', 'admin=attendance', reqJson, callBackData); + } else { + const label = $(`#${this.getTableName()}Form .label`); + label.html(msg); + label.show(); + } + } + } + + + saveSuccessCallback(callBackData) { + this.get(callBackData); + } + + + saveFailCallback(callBackData) { + this.showMessage('Error saving attendance entry', callBackData); + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } + + showPunchImages(id) { + const reqJson = JSON.stringify({ id }); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getImagesSuccessCallback'; + callBackData.callBackFail = 'getImagesFailCallback'; + this.customAction('getImages', 'admin=attendance', reqJson, callBackData); + } + + getImagesSuccessCallback(callBackData) { + $('#attendancePhotoModel').modal('show'); + $('#attendnaceCanvasEmp').html(callBackData.employee_Name); + if (callBackData.in_time) { + $('#attendnaceCanvasPunchInTime').html(Date.parse(callBackData.in_time).toString('yyyy MMM d HH:mm')); + } + + if (callBackData.image_in) { + const myCanvas = document.getElementById('attendnaceCanvasIn'); + const ctx = myCanvas.getContext('2d'); + const img = new Image(); + img.onload = function () { + ctx.drawImage(img, 0, 0); // Or at whatever offset you like + }; + img.src = callBackData.image_in; + } + + if (callBackData.out_time) { + $('#attendnaceCanvasPunchOutTime').html(Date.parse(callBackData.out_time).toString('yyyy MMM d HH:mm')); + } + + if (callBackData.image_out) { + const myCanvas = document.getElementById('attendnaceCanvasOut'); + const ctx = myCanvas.getContext('2d'); + const img = new Image(); + img.onload = function () { + ctx.drawImage(img, 0, 0); // Or at whatever offset you like + }; + img.src = callBackData.image_out; + } + } + + + getImagesFailCallback(callBackData) { + this.showMessage('Error', callBackData); + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + const deleteButton = ''; + const photoButton = ''; + + let html; + if (this.photoAttendance === 1) { + html = '
    _edit__delete__photo_
    '; + } else { + html = '
    _edit__delete_
    '; + } + + html = html.replace('_photo_', photoButton); + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + + +/* + Attendance Status + */ + +class AttendanceStatusAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Clocked In Status' }, + ]; + } + + getFormFields() { + return [ + + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': false, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_BASE_/g, this.baseUrl); + if (data[2] == 'Not Clocked In') { + html = html.replace(/_COLOR_/g, 'gray'); + } else if (data[2] == 'Clocked Out') { + html = html.replace(/_COLOR_/g, 'yellow'); + } else if (data[2] == 'Clocked In') { + html = html.replace(/_COLOR_/g, 'green'); + } + return html; + } + + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + +module.exports = { AttendanceAdapter, AttendanceStatusAdapter }; diff --git a/web/admin/src/company_structure/index.js b/web/admin/src/company_structure/index.js new file mode 100644 index 00000000..ad9610d7 --- /dev/null +++ b/web/admin/src/company_structure/index.js @@ -0,0 +1,4 @@ +import { CompanyStructureAdapter, CompanyGraphAdapter } from './lib'; + +window.CompanyStructureAdapter = CompanyStructureAdapter; +window.CompanyGraphAdapter = CompanyGraphAdapter; diff --git a/web/admin/src/company_structure/lib.js b/web/admin/src/company_structure/lib.js new file mode 100644 index 00000000..598d57e6 --- /dev/null +++ b/web/admin/src/company_structure/lib.js @@ -0,0 +1,311 @@ +/* eslint-disable prefer-destructuring */ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global d3, nv */ + +import AdapterBase from '../../../api/AdapterBase'; + +class CompanyStructureAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'title', + 'address', + 'type', + 'country', + 'timezone', + 'parent', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Address', bSortable: false }, + { sTitle: 'Type' }, + { sTitle: 'Country', sClass: 'center' }, + { sTitle: 'Time Zone' }, + { sTitle: 'Parent Structure' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['title', { label: 'Name', type: 'text', validation: '' }], + ['description', { label: 'Details', type: 'textarea', validation: '' }], + ['address', { label: 'Address', type: 'textarea', validation: 'none' }], + ['type', { label: 'Type', type: 'select', source: [['Company', 'Company'], ['Head Office', 'Head Office'], ['Regional Office', 'Regional Office'], ['Department', 'Department'], ['Unit', 'Unit'], ['Sub Unit', 'Sub Unit'], ['Other', 'Other']] }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ['timezone', { + label: 'Time Zone', type: 'select2', 'allow-null': false, 'remote-source': ['Timezone', 'name', 'details'], + }], + ['parent', { + label: 'Parent Structure', type: 'select', 'allow-null': true, 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['heads', { + label: 'Heads', type: 'select2multi', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + postRenderForm(object, $tempDomObj) { + if (object === undefined + || object === null + || object.id === null + || object.id === undefined || object.id === '' + ) { + $tempDomObj.find('#field_heads').hide(); + } + } +} + + +/* + * Company Graph + */ + + +class CompanyGraphAdapter extends CompanyStructureAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.nodeIdCounter = 0; + } + + convertToTree(data) { + const ice = {}; + ice.id = -1; + ice.title = ''; + ice.name = ''; + ice.children = []; + + let parent = null; + + const added = {}; + + + for (let i = 0; i < data.length; i++) { + data[i].name = data[i].title; + + if (data[i].parent != null && data[i].parent !== undefined) { + parent = this.findParent(data, data[i].parent); + if (parent != null) { + if (parent.children === undefined || parent.children == null) { + parent.children = []; + } + parent.children.push(data[i]); + } + } + } + + for (let i = 0; i < data.length; i++) { + if (data[i].parent == null || data[i].parent === undefined) { + ice.children.push(data[i]); + } + } + + return ice; + } + + + findParent(data, parent) { + for (let i = 0; i < data.length; i++) { + if (data[i].title === parent || data[i].title === parent) { + return data[i]; + } + } + return null; + } + + + createTable(elementId) { + $('#tabPageCompanyGraph').html(''); + const that = this; + const sourceData = this.sourceData; + + // this.fixCyclicParent(sourceData); + const treeData = this.convertToTree(sourceData); + const m = [20, 120, 20, 120]; + const w = 5000 - m[1] - m[3]; + const h = 1000 - m[0] - m[2]; + + const tree = d3.layout.tree() + .size([h, w]); + + this.diagonal = d3.svg.diagonal() + .projection(d => [d.y, d.x]); + + this.vis = d3.select('#tabPageCompanyGraph').append('svg:svg') + .attr('width', w + m[1] + m[3]) + .attr('height', h + m[0] + m[2]) + .append('svg:g') + .attr('transform', `translate(${m[3]},${m[0]})`); + + const root = treeData; + root.x0 = h / 2; + root.y0 = 0; + + function toggleAll(d) { + if (d.children) { + console.log(d.name); + d.children.forEach(toggleAll); + that.toggle(d); + } + } + this.update(root, tree, root); + } + + update(source, tree, root) { + const that = this; + const duration = d3.event && d3.event.altKey ? 5000 : 500; + + // Compute the new tree layout. + const nodes = tree.nodes(root).reverse(); + + // Normalize for fixed-depth. + nodes.forEach((d) => { d.y = d.depth * 180; }); + + // Update the nodes� + const node = that.vis.selectAll('g.node') + .data(nodes, d => d.id || (d.id = ++that.nodeIdCounter)); + + // Enter any new nodes at the parent's previous position. + const nodeEnter = node.enter().append('svg:g') + .attr('class', 'node') + .attr('transform', d => `translate(${source.y0},${source.x0})`) + .on('click', (d) => { that.toggle(d); that.update(d, tree, root); }); + + nodeEnter.append('svg:circle') + .attr('r', 1e-6) + .style('fill', d => (d._children ? 'lightsteelblue' : '#fff')); + + nodeEnter.append('svg:text') + .attr('x', d => (d.children || d._children ? -10 : 10)) + .attr('dy', '.35em') + .attr('text-anchor', d => (d.children || d._children ? 'end' : 'start')) + .text(d => d.name) + .style('fill-opacity', 1e-6); + + // Transition nodes to their new position. + const nodeUpdate = node.transition() + .duration(duration) + .attr('transform', d => `translate(${d.y},${d.x})`); + + nodeUpdate.select('circle') + .attr('r', 4.5) + .style('fill', d => (d._children ? 'lightsteelblue' : '#fff')); + + nodeUpdate.select('text') + .style('fill-opacity', 1); + + // Transition exiting nodes to the parent's new position. + const nodeExit = node.exit().transition() + .duration(duration) + .attr('transform', d => `translate(${source.y},${source.x})`) + .remove(); + + nodeExit.select('circle') + .attr('r', 1e-6); + + nodeExit.select('text') + .style('fill-opacity', 1e-6); + + // Update the links� + const link = that.vis.selectAll('path.link') + .data(tree.links(nodes), d => d.target.id); + + // Enter any new links at the parent's previous position. + link.enter().insert('svg:path', 'g') + .attr('class', 'link') + .attr('d', (d) => { + const o = { x: source.x0, y: source.y0 }; + return that.diagonal({ source: o, target: o }); + }) + .transition() + .duration(duration) + .attr('d', that.diagonal); + + // Transition links to their new position. + link.transition() + .duration(duration) + .attr('d', that.diagonal); + + // Transition exiting nodes to the parent's new position. + link.exit().transition() + .duration(duration) + .attr('d', (d) => { + const o = { x: source.x, y: source.y }; + return that.diagonal({ source: o, target: o }); + }) + .remove(); + + // Stash the old positions for transition. + nodes.forEach((d) => { + d.x0 = d.x; + d.y0 = d.y; + }); + } + + // Toggle children. + toggle(d) { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + } + + + getSourceDataById(id) { + for (let i = 0; i < this.sourceData.length; i++) { + if (this.sourceData[i].id == id) { + return this.sourceData[i]; + } + } + + return null; + } + + fixCyclicParent(sourceData) { + let errorMsg = ''; + for (let i = 0; i < sourceData.length; i++) { + const obj = sourceData[i]; + + + let curObj = obj; + const parentIdArr = {}; + parentIdArr[curObj.id] = 1; + + while (curObj.parent != null && curObj.parent != undefined) { + const parent = this.getSourceDataById(curObj.parent); + if (parent == null) { + break; + } else if (parentIdArr[parent.id] == 1) { + errorMsg = `${obj.title}'s parent structure set to ${parent.title}
    `; + obj.parent = null; + break; + } + parentIdArr[parent.id] = 1; + curObj = parent; + } + } + + if (errorMsg !== '') { + this.showMessage('Company Structure is having a cyclic dependency', `We found a cyclic dependency due to following reasons:
    ${errorMsg}`); + return false; + } + + return true; + } + + getHelpLink() { + return 'https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html'; + } +} + +module.exports = { CompanyStructureAdapter, CompanyGraphAdapter }; diff --git a/web/admin/src/dashboard/index.js b/web/admin/src/dashboard/index.js new file mode 100644 index 00000000..636c6706 --- /dev/null +++ b/web/admin/src/dashboard/index.js @@ -0,0 +1,3 @@ +import { DashboardAdapter } from './lib'; + +window.DashboardAdapter = DashboardAdapter; diff --git a/web/admin/src/dashboard/lib.js b/web/admin/src/dashboard/lib.js new file mode 100644 index 00000000..ba91bab3 --- /dev/null +++ b/web/admin/src/dashboard/lib.js @@ -0,0 +1,56 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +class DashboardAdapter extends AdapterBase { + getDataMapping() { + return []; + } + + getHeaders() { + return []; + } + + getFormFields() { + return []; + } + + + get(callBackData) { + } + + + getInitData() { + const that = this; + const object = {}; + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getInitDataSuccessCallBack'; + callBackData.callBackFail = 'getInitDataFailCallBack'; + + this.customAction('getInitData', 'admin=dashboard', reqJson, callBackData); + } + + + getInitDataSuccessCallBack(data) { + $('#numberOfEmployees').html(`${data.numberOfEmployees} Employees`); + $('#numberOfCompanyStuctures').html(`${data.numberOfCompanyStuctures} Departments`); + $('#numberOfUsers').html(`${data.numberOfUsers} Users`); + $('#numberOfProjects').html(`${data.numberOfProjects} Active Projects`); + $('#numberOfAttendanceLastWeek').html(`${data.numberOfAttendanceLastWeek} Entries Last Week`); + $('#numberOfLeaves').html(`${data.numberOfLeaves} Upcoming`); + $('#numberOfTimeEntries').html(data.numberOfTimeEntries); + $('#numberOfCandidates').html(`${data.numberOfCandidates} Candidates`); + $('#numberOfJobs').html(`${data.numberOfJobs} Active`); + $('#numberOfCourses').html(`${data.numberOfCourses} Courses`); + } + + getInitDataFailCallBack(callBackData) { + + } +} + +module.exports = { DashboardAdapter }; diff --git a/web/admin/src/data/index.js b/web/admin/src/data/index.js new file mode 100644 index 00000000..1c23c3c7 --- /dev/null +++ b/web/admin/src/data/index.js @@ -0,0 +1,4 @@ +import { DataImportAdapter, DataImportFileAdapter } from './lib'; + +window.DataImportAdapter = DataImportAdapter; +window.DataImportFileAdapter = DataImportFileAdapter; diff --git a/web/admin/src/data/lib.js b/web/admin/src/data/lib.js new file mode 100644 index 00000000..1db52293 --- /dev/null +++ b/web/admin/src/data/lib.js @@ -0,0 +1,185 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global dependOnField */ +import AdapterBase from '../../../api/AdapterBase'; + +/** + * DataImportAdapter + */ + +class DataImportAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'dataType', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Data Type' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['dataType', { label: 'Data Type', type: 'text', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['columns', { + label: 'Columns', + type: 'datagroup', + form: [ + ['name', { label: 'Name', type: 'text', validation: '' }], + ['title', { label: 'Filed Title', type: 'text', validation: 'none' }], + ['type', { + label: 'Type', type: 'select', sort: 'none', source: [['Normal', 'Normal'], ['Reference', 'Reference'], ['Attached', 'Attached']], + }], + ['dependOn', { + label: 'Depends On', + type: 'select', + 'allow-null': true, + 'null-label': 'N/A', + source: [['EmergencyContact', 'Emergency Contacts'], ['Ethnicity', 'Ethnicity'], ['Nationality', 'Nationality'], ['JobTitle', 'JobTitle'], ['PayFrequency', 'PayFrequency'], ['PayGrade', 'PayGrade'], ['EmploymentStatus', 'EmploymentStatus'], ['CompanyStructure', 'CompanyStructure'], ['Employee', 'Employee']], + }], + ['dependOnField', { label: 'Depends On Field', type: 'text', validation: 'none' }], + ['isKeyField', { + label: 'Is Key Field', type: 'select', validation: '', source: [['No', 'No'], ['Yes', 'Yes']], + }], + ['idField', { + label: 'Is ID Field', type: 'select', validation: '', source: [['No', 'No'], ['Yes', 'Yes']], + }], + ], + html: '
    #_name_# #_delete_##_edit_#
    Header Title: #_title_#
    Type: #_type_#
    ', + validation: 'none', + 'custom-validate-function': function (data) { + const res = {}; + res.params = data; + res.valid = true; + if (data.type === 'Reference') { + if (data.dependOn === 'NULL') { + res.message = 'If the type is Reference this field should referring another table'; + res.valid = false; + } else if (dependOnField === null || dependOnField === undefined) { + res.message = "If the type is Reference then 'Depends On Field' can not be empty"; + res.valid = false; + } + } + + return res; + }, + + }], + ]; + } +} + + +/** + * DataImportFileAdapter + */ + +class DataImportFileAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'data_import_definition', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Data Import Definition' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['data_import_definition', { label: 'Data Import Definitions', type: 'select', 'remote-source': ['DataImport', 'id', 'name'] }], + ['file', { + label: 'File to Import', type: 'fileupload', validation: '', filetypes: 'csv,txt', + }], + ['details', { label: 'Last Export Result', type: 'textarea', validation: 'none' }], + ]; + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + const processButton = ''; + const deleteButton = ''; + const cloneButton = ''; + + let html = '
    _edit__process__clone__delete_
    '; + + + if (this.showAddNew) { + html = html.replace('_clone_', cloneButton); + } else { + html = html.replace('_clone_', ''); + } + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + if (data[3] === 'Not Processed') { + html = html.replace('_process_', processButton); + } else { + html = html.replace('_process_', ''); + } + + + html = html.replace(/_id_/g, id); + html = html.replace(/_status_/g, data[6]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + process(id) { + const that = this; + const object = { id }; + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'processSuccessCallBack'; + callBackData.callBackFail = 'processFailCallBack'; + + this.customAction('processDataFile', 'admin=data', reqJson, callBackData); + } + + processSuccessCallBack(callBackData) { + this.showMessage('Success', 'File imported successfully.'); + } + + + processFailCallBack(callBackData) { + this.showMessage('Error', `File import unsuccessful. Result:${callBackData}`); + } +} + +module.exports = { DataImportAdapter, DataImportFileAdapter }; diff --git a/web/admin/src/employees/index.js b/web/admin/src/employees/index.js new file mode 100644 index 00000000..bf8bb349 --- /dev/null +++ b/web/admin/src/employees/index.js @@ -0,0 +1,39 @@ +import { + EmployeeAdapter, + TerminatedEmployeeAdapter, + ArchivedEmployeeAdapter, + EmployeeSkillAdapter, + EmployeeEducationAdapter, + EmployeeCertificationAdapter, + EmployeeLanguageAdapter, + EmployeeDependentAdapter, + EmergencyContactAdapter, + EmployeeImmigrationAdapter, + EmployeeSubSkillsAdapter, + EmployeeSubEducationAdapter, + EmployeeSubCertificationAdapter, + EmployeeSubLanguageAdapter, + EmployeeSubDependentAdapter, + EmployeeSubEmergencyContactAdapter, + EmployeeSubDocumentAdapter, + EmployeeDocumentAdapter, +} from './lib'; + +window.EmployeeAdapter = EmployeeAdapter; +window.TerminatedEmployeeAdapter = TerminatedEmployeeAdapter; +window.ArchivedEmployeeAdapter = ArchivedEmployeeAdapter; +window.EmployeeSkillAdapter = EmployeeSkillAdapter; +window.EmployeeEducationAdapter = EmployeeEducationAdapter; +window.EmployeeCertificationAdapter = EmployeeCertificationAdapter; +window.EmployeeLanguageAdapter = EmployeeLanguageAdapter; +window.EmployeeDependentAdapter = EmployeeDependentAdapter; +window.EmergencyContactAdapter = EmergencyContactAdapter; +window.EmployeeImmigrationAdapter = EmployeeImmigrationAdapter; +window.EmployeeSubSkillsAdapter = EmployeeSubSkillsAdapter; +window.EmployeeSubEducationAdapter = EmployeeSubEducationAdapter; +window.EmployeeSubCertificationAdapter = EmployeeSubCertificationAdapter; +window.EmployeeSubLanguageAdapter = EmployeeSubLanguageAdapter; +window.EmployeeSubDependentAdapter = EmployeeSubDependentAdapter; +window.EmployeeSubEmergencyContactAdapter = EmployeeSubEmergencyContactAdapter; +window.EmployeeSubDocumentAdapter = EmployeeSubDocumentAdapter; +window.EmployeeDocumentAdapter = EmployeeDocumentAdapter; diff --git a/web/admin/src/employees/lib.js b/web/admin/src/employees/lib.js new file mode 100644 index 00000000..9d0a5486 --- /dev/null +++ b/web/admin/src/employees/lib.js @@ -0,0 +1,1877 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/* eslint-disable prefer-destructuring,no-restricted-globals */ + +/* global Base64, modJs, nl2br, ga */ +/** + * Author: Thilina Hasantha + */ + +import AdapterBase from '../../../api/AdapterBase'; +import SubAdapterBase from '../../../api/SubAdapterBase'; + +/** + * @class EmployeeSubSkillsAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + + +class EmployeeSubSkillsAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'skill_id', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Skill' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'remote-source': ['Skill', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: '' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Skills'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + const itemHtml = $(`
    ${item[2]}${itemDelete}${itemEdit}

    ${nl2br(item[3])}

    `); + return itemHtml; + } +} + + +/** + * @class EmployeeSubEducationAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + + +class EmployeeSubEducationAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'education_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Qualification' }, + { sTitle: 'Institute' }, + { sTitle: 'Start Date' }, + { sTitle: 'Completed On' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': false, 'remote-source': ['Education', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Start Date', type: 'date', validation: 'none' }], + ['date_end', { label: 'Completed On', type: 'date', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Education'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + let start = ''; + try { + start = Date.parse(item[4]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + + let end = ''; + try { + end = Date.parse(item[5]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + // eslint-disable-next-line max-len + return $(`
    ${item[2]}${itemDelete}${itemEdit}

    Start: ${start}

    Completed: ${end}

    ` + + ` Institute: ${item[3]}

    `); + } +} + + +/** + * @class EmployeeSubCertificationAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubCertificationAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'certification_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Certification' }, + { sTitle: 'Institute' }, + { sTitle: 'Granted On' }, + { sTitle: 'Valid Thru' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': false, 'remote-source': ['Certification', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Granted On', type: 'date', validation: 'none' }], + ['date_end', { label: 'Valid Thru', type: 'date', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Certifications'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + let start = ''; + try { + start = Date.parse(item[4]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + + let end = ''; + try { + end = Date.parse(item[5]).toString('MMM d, yyyy'); + } catch (e) { + console.log(`Error:${e.message}`); + } + // eslint-disable-next-line max-len + return $(`
    ${item[2]}${itemDelete}${itemEdit}

    Granted On: ${start}

    Valid Thru: ${end}

    Institute: ${item[3]}

    `); + } +} + +/** + * @class EmployeeSubLanguageAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubLanguageAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'language_id', + 'reading', + 'speaking', + 'writing', + 'understanding', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Language' }, + { sTitle: 'Reading' }, + { sTitle: 'Speaking' }, + { sTitle: 'Writing' }, + { sTitle: 'Understanding' }, + ]; + } + + getFormFields() { + const compArray = [['Elementary Proficiency', 'Elementary Proficiency'], + ['Limited Working Proficiency', 'Limited Working Proficiency'], + ['Professional Working Proficiency', 'Professional Working Proficiency'], + ['Full Professional Proficiency', 'Full Professional Proficiency'], + ['Native or Bilingual Proficiency', 'Native or Bilingual Proficiency']]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': false, 'remote-source': ['Language', 'id', 'name'], + }], + ['reading', { label: 'Reading', type: 'select', source: compArray }], + ['speaking', { label: 'Speaking', type: 'select', source: compArray }], + ['writing', { label: 'Writing', type: 'select', source: compArray }], + ['understanding', { label: 'Understanding', type: 'select', source: compArray }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Languages'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + // eslint-disable-next-line max-len + return $(`
    ${item[2]}${itemDelete}${itemEdit}

    Reading: ${item[3]}

    Speaking: ${item[4]}

    Writing: ${item[5]}

    Understanding: ${item[6]}

    `); + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * @class EmployeeSubDependentAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubDependentAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'dob', + 'id_number', + ]; + } + + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Date of Birth' }, + { sTitle: 'Id Number' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'select', source: [['Child', 'Child'], ['Spouse', 'Spouse'], ['Parent', 'Parent'], ['Other', 'Other']] }], + ['dob', { label: 'Date of Birth', type: 'date', validation: '' }], + ['id_number', { label: 'Id Number', type: 'text', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Dependents'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + // eslint-disable-next-line max-len + const itemHtml = $(`
    ${item[2]}${itemDelete}${itemEdit}

    Relationship: ${item[3]}

    Name: ${item[2]}

    `); + return itemHtml; + } +} + + +/** + * @class EmployeeSubEmergencyContactAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubEmergencyContactAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'home_phone', + 'work_phone', + 'mobile_phone', + ]; + } + + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Home Phone' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Mobile Phone' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Emergency Contacts'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + // eslint-disable-next-line max-len + const itemHtml = $(`
    ${item[2]}${itemDelete}${itemEdit}

    Relationship: ${item[3]}

    Name: ${item[2]}

    Home Phone: ${item[4]}

    Mobile Phone: ${item[6]}

    `); + return itemHtml; + } +} + +/** + * @class EmployeeSubDocumentAdapter + * @param endPoint + * @param tab + * @param filter + * @param orderBy + * @returns + */ + +class EmployeeSubDocumentAdapter extends SubAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'details', + 'date_added', + 'valid_until', + 'status', + 'attachment', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document' }, + { sTitle: 'Details' }, + { sTitle: 'Date Added' }, + { sTitle: 'Status' }, + { sTitle: 'Attachment', bVisible: false }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'hidden' }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['Document', 'id', 'name'] }], + ['date_added', { label: 'Date Added', type: 'date', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]; + } + + + forceInjectValuesBeforeSave(params) { + params.employee = this.parent.currentId; + return params; + } + + getSubHeaderTitle() { + const addBtn = ``; + return addBtn + this.gt('Documents'); + } + + getSubItemHtml(item, itemDelete, itemEdit) { + let expire = ''; + try { + expire = Date.parse(item[5]).toString('MMM d, yyyy'); + } catch (e) { + console.log(e.message); + } + + const downloadButton = ``; + + const itemHtml = $(`
    ${item[2]}${downloadButton}${itemDelete}${itemEdit}

    ${nl2br(item[3])}

    Expire On: ${expire}

    `); + return itemHtml; + } + + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + +class SubProfileEnabledAdapterBase extends AdapterBase { + isSubProfileTable() { + if (this.user.user_level === 'Admin') { + return false; + } + return true; + } +} + + +class EmployeeAdapter extends SubProfileEnabledAdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.fieldNameMap = {}; + this.hiddenFields = {}; + this.tableFields = {}; + this.formOnlyFields = {}; + } + + setFieldNameMap(fields) { + let field; + for (let i = 0; i < fields.length; i++) { + field = fields[i]; + this.fieldNameMap[field.name] = field; + if (field.display === 'Hidden') { + this.hiddenFields[field.name] = field; + } else if (field.display === 'Table and Form' || field.display === 'Form') { + this.tableFields[field.name] = field; + } else { + this.formOnlyFields[field.name] = field; + } + } + } + + getCustomTableParams() { + const that = this; + return { + aoColumnDefs: [ + { + fnRender(data, cell) { + return that.preProcessRemoteTableData(data, cell, 1); + }, + aTargets: [1], + }, + { + fnRender: that.getActionButtons, + aTargets: [that.getDataMapping().length], + }, + ], + }; + } + + preProcessRemoteTableData(data, cell, id) { + if (id === 1) { + const tmp = 'User Image'; + return tmp.replace('_img_', cell); + } + return cell; + } + + getTableHTMLTemplate() { + return '
    '; + } + + getTableFields() { + return [ + 'id', + 'image', + 'employee_id', + 'first_name', + 'last_name', + 'mobile_phone', + 'department', + 'gender', + 'supervisor', + ]; + } + + getDataMapping() { + const tableFields = this.getTableFields(); + + const newTableFields = []; + for (let i = 0; i < tableFields.length; i++) { + if ((this.hiddenFields[tableFields[i]] === undefined || this.hiddenFields[tableFields[i]] === null) + && (this.formOnlyFields[tableFields[i]] === undefined || this.formOnlyFields[tableFields[i]] === null)) { + newTableFields.push(tableFields[i]); + } + } + + return newTableFields; + } + + getHeaders() { + const tableFields = this.getTableFields(); + const headers = [ + { sTitle: 'ID', bVisible: false }, + { sTitle: '', bSortable: false }, + ]; + let title = ''; + + for (let i = 0; i < tableFields.length; i++) { + if ((this.hiddenFields[tableFields[i]] === undefined || this.hiddenFields[tableFields[i]] === null) + && (this.formOnlyFields[tableFields[i]] === undefined || this.formOnlyFields[tableFields[i]] === null)) { + if (this.fieldNameMap[tableFields[i]] !== undefined && this.fieldNameMap[tableFields[i]] !== null) { + title = this.fieldNameMap[tableFields[i]].textMapped; + if (title === undefined || title === null || title === '') { + headers.push({ sTitle: title }); + } else if (tableFields[i] === 'gender') { + headers.push({ sTitle: title, translate: true }); + } else { + headers.push({ sTitle: title }); + } + } + } + } + + return headers; + } + + getFormFields() { + const newFields = []; + let tempField; let + title; + const fields = [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['nationality', { label: 'Nationality', type: 'select2', 'remote-source': ['Nationality', 'id', 'name'] }], + ['birthday', { label: 'Date of Birth', type: 'date', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['marital_status', { label: 'Marital Status', type: 'select', source: [['Married', 'Married'], ['Single', 'Single'], ['Divorced', 'Divorced'], ['Widowed', 'Widowed'], ['Other', 'Other']] }], + ['ethnicity', { + label: 'Ethnicity', type: 'select2', 'allow-null': true, 'remote-source': ['Ethnicity', 'id', 'name'], + }], + ['immigration_status', { + label: 'Immigration Status', type: 'select2', 'allow-null': true, 'remote-source': ['ImmigrationStatus', 'id', 'name'], + }], + ['ssn_num', { label: 'SSN/NRIC', type: 'text', validation: 'none' }], + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + ['employment_status', { label: 'Employment Status', type: 'select2', 'remote-source': ['EmploymentStatus', 'id', 'name'] }], + ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], + ['pay_grade', { + label: 'Pay Grade', type: 'select2', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'], + }], + ['work_station_id', { label: 'Work Station Id', type: 'text', validation: 'none' }], + ['address1', { label: 'Address Line 1', type: 'text', validation: 'none' }], + ['address2', { label: 'Address Line 2', type: 'text', validation: 'none' }], + ['city', { label: 'City', type: 'text', validation: 'none' }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ['province', { + label: 'State', type: 'select2', 'allow-null': true, 'remote-source': ['Province', 'id', 'name'], + }], + ['postal_code', { label: 'Postal/Zip Code', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['work_email', { label: 'Work Email', type: 'text', validation: 'emailOrEmpty' }], + ['private_email', { label: 'Private Email', type: 'text', validation: 'emailOrEmpty' }], + ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }], + ['confirmation_date', { label: 'Confirmation Date', type: 'date', validation: 'none' }], + ['termination_date', { label: 'Termination Date', type: 'date', validation: 'none' }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['supervisor', { + label: 'Direct Supervisor', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['indirect_supervisors', { + label: 'Indirect Supervisors', type: 'select2multi', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['approver1', { + label: 'First Level Approver', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['approver2', { + label: 'Second Level Approver', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['approver3', { + label: 'Third Level Approver', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['notes', { + label: 'Notes', + type: 'datagroup', + form: [ + ['note', { label: 'Note', type: 'textarea', validation: '' }], + ], + html: '
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ', + validation: 'none', + 'sort-function': function (a, b) { + const t1 = Date.parse(a.date).getTime(); + const t2 = Date.parse(b.date).getTime(); + + return (t1 < t2); + }, + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + data.date = new Date().toString('d-MMM-yyyy hh:mm tt'); + res.params = data; + return res; + }, + + }], + ]; + + for (let i = 0; i < this.customFields.length; i++) { + fields.push(this.customFields[i]); + } + + for (let i = 0; i < fields.length; i++) { + tempField = fields[i]; + if (this.hiddenFields[tempField[0]] === undefined || this.hiddenFields[tempField[0]] === null) { + if (this.fieldNameMap[tempField[0]] !== undefined && this.fieldNameMap[tempField[0]] !== null) { + title = this.fieldNameMap[tempField[0]].textMapped; + tempField[1].label = title; + } + newFields.push(tempField); + } + } + + return newFields; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'null-label': 'Anyone', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getActionButtonsHtml(id) { + let deleteBtn = ''; + if (this.showDelete === false) { + deleteBtn = ''; + } + // eslint-disable-next-line max-len + let html = `
    ${deleteBtn}
    `; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + getHelpLink() { + return 'https://thilinah.gitbooks.io/icehrm-guide/content/employee-information-setup.html'; + } + + saveSuccessItemCallback(data) { + this.lastSavedEmployee = data; + if (this.currentId === null) { + $('#createUserModel').modal('show'); + } + } + + closeCreateUser() { + $('#createUserModel').modal('hide'); + } + + createUser() { + const data = {}; + data.employee = this.lastSavedEmployee.id; + data.user_level = 'Employee'; + data.email = this.lastSavedEmployee.work_email; + data.username = this.lastSavedEmployee.work_email.split('@')[0]; + top.location.href = this.getCustomUrl( + `?g=admin&n=users&m=admin_Admin&action=new&object=${ + Base64.encodeURI(JSON.stringify(data))}`, + ); + } + + deleteEmployee(id) { + if (confirm('Are you sure you want to archive this employee? Data for this employee will be saved to an archive table. But you will not be able to covert the archived employee data into a normal employee.')) { + // Archive + } else { + return; + } + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'deleteEmployeeSuccessCallback'; + callBackData.callBackFail = 'deleteEmployeeFailCallback'; + + this.customAction( + 'deleteEmployee', + 'admin=employees', + JSON.stringify({ id }), callBackData, + ); + } + + + deleteEmployeeSuccessCallback(callBackData) { + this.showMessage('Delete Success', 'Employee deleted. You can find archived information for this employee in Archived Employees tab'); + this.get([]); + } + + + deleteEmployeeFailCallback(callBackData) { + this.showMessage('Error occurred while deleting Employee', callBackData); + } + + + terminateEmployee(id) { + if (confirm('Are you sure you want to terminate this employee contract? You will still be able to access all details of this employee.')) { + // Terminate + } else { + return; + } + + const params = {}; + params.id = id; + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'terminateEmployeeSuccessCallback'; + callBackData.callBackFail = 'terminateEmployeeFailCallback'; + + this.customAction('terminateEmployee', 'admin=employees', reqJson, callBackData); + } + + + terminateEmployeeSuccessCallback(callBackData) { + this.showMessage('Success', 'Employee contract terminated. You can find terminated employee information under Terminated Employees menu.'); + this.get([]); + } + + + terminateEmployeeFailCallback(callBackData) { + this.showMessage('Error occured while terminating Employee', callBackData); + } + + + activateEmployee(id) { + if (confirm('Are you sure you want to re-activate this employee contract?')) { + // Terminate + } else { + return; + } + + const params = {}; + params.id = id; + const reqJson = JSON.stringify(params); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'activateEmployeeSuccessCallback'; + callBackData.callBackFail = 'activateEmployeeFailCallback'; + + this.customAction('activateEmployee', 'admin=employees', reqJson, callBackData); + } + + + activateEmployeeSuccessCallback(callBackData) { + this.showMessage('Success', 'Employee contract re-activated.'); + this.get([]); + } + + + activateEmployeeFailCallback(callBackData) { + this.showMessage('Error occurred while activating Employee', callBackData); + } + + + view(id) { + const that = this; + this.currentId = id; + const sourceMappingJson = JSON.stringify(this.getSourceMapping()); + const object = { id, map: sourceMappingJson }; + const reqJson = JSON.stringify(object); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'renderEmployee'; + callBackData.callBackFail = 'viewFailCallBack'; + + this.customAction('get', 'modules=employees', reqJson, callBackData); + } + + + viewFailCallBack(callBackData) { + this.showMessage('Error', 'Error Occured while retriving candidate'); + } + + renderEmployee(data) { + let title; + const fields = this.getFormFields(); + const currentEmpId = data[1]; + const currentId = data[1]; + const userEmpId = data[2]; + data = data[0]; + this.currentEmployee = data; + let html = this.getCustomTemplate('myDetails.html'); + + + for (let i = 0; i < fields.length; i++) { + if (this.fieldNameMap[fields[i][0]] !== undefined && this.fieldNameMap[fields[i][0]] !== null) { + title = this.gt(this.fieldNameMap[fields[i][0]].textMapped); + html = html.replace(`#_label_${fields[i][0]}_#`, title); + } + } + + html = html.replace(/#_.+_#/gi, ''); + html = html.replace(/_id_/g, data.id); + + $(`#${this.getTableName()}`).html(html); + + for (let i = 0; i < fields.length; i++) { + $(`#${this.getTableName()} #${fields[i][0]}`).html(data[fields[i][0]]); + $(`#${this.getTableName()} #${fields[i][0]}_Name`).html(data[`${fields[i][0]}_Name`]); + } + + let subordinates = ''; + for (let i = 0; i < data.subordinates.length; i++) { + if (data.subordinates[i].first_name !== undefined && data.subordinates[i].first_name !== null) { + subordinates += `${data.subordinates[i].first_name} `; + } + + if (data.subordinates[i].middle_name !== undefined && data.subordinates[i].middle_name !== null && data.subordinates[i].middle_name !== '') { + subordinates += `${data.subordinates[i].middle_name} `; + } + + if (data.subordinates[i].last_name !== undefined && data.subordinates[i].last_name !== null && data.subordinates[i].last_name !== '') { + subordinates += data.subordinates[i].last_name; + } + subordinates += '
    '; + } + + $(`#${this.getTableName()} #subordinates`).html(subordinates); + + + $(`#${this.getTableName()} #name`).html(`${data.first_name} ${data.last_name}`); + this.currentUserId = data.id; + + $(`#${this.getTableName()} #profile_image_${data.id}`).attr('src', data.image); + + + // Add custom fields + if (data.customFields !== undefined && data.customFields !== null && Object.keys(data.customFields).length > 0) { + const ct = '
    '; + + const sectionTemplate = '

    #_section.name_#

    '; + let customFieldHtml; + for (const index in data.customFields) { + if (!data.customFields[index][1]) { + data.customFields[index][1] = this.gt('Other Details'); + } + + let sectionId = data.customFields[index][1].toLocaleLowerCase(); + sectionId = sectionId.replace(' ', '_'); + + if ($(`#cont_${sectionId}`).length <= 0) { + // Add section + let sectionHtml = sectionTemplate; + sectionHtml = sectionHtml.replace('#_section_#', sectionId); + sectionHtml = sectionHtml.replace('#_section.name_#', data.customFields[index][1]); + $('#customFieldsCont').append($(sectionHtml)); + } + + customFieldHtml = ct; + customFieldHtml = customFieldHtml.replace('#_label_#', index); + if (data.customFields[index][2] === 'fileupload') { + customFieldHtml = customFieldHtml.replace( + '#_value_#', + ``, + ); + } else { + customFieldHtml = customFieldHtml.replace('#_value_#', data.customFields[index][0]); + } + $(`#cont_${sectionId}`).append($(customFieldHtml)); + } + } else { + $('#customFieldsCont').remove(); + } + + + this.cancel(); + + if (!this.isModuleInstalled('admin', 'documents')) { + $('#tabDocuments').remove(); + } + + + window.modJs = this; + modJs.subModJsList = []; + + modJs.subModJsList.tabEmployeeSkillSubTab = new EmployeeSubSkillsAdapter('EmployeeSkill', 'EmployeeSkillSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeSkillSubTab.parent = this; + + modJs.subModJsList.tabEmployeeEducationSubTab = new EmployeeSubEducationAdapter('EmployeeEducation', 'EmployeeEducationSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeEducationSubTab.parent = this; + + modJs.subModJsList.tabEmployeeCertificationSubTab = new EmployeeSubCertificationAdapter('EmployeeCertification', 'EmployeeCertificationSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeCertificationSubTab.parent = this; + + modJs.subModJsList.tabEmployeeLanguageSubTab = new EmployeeSubLanguageAdapter('EmployeeLanguage', 'EmployeeLanguageSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeLanguageSubTab.parent = this; + + modJs.subModJsList.tabEmployeeDependentSubTab = new EmployeeSubDependentAdapter('EmployeeDependent', 'EmployeeDependentSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeDependentSubTab.parent = this; + + modJs.subModJsList.tabEmployeeEmergencyContactSubTab = new EmployeeSubEmergencyContactAdapter('EmergencyContact', 'EmployeeEmergencyContactSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.parent = this; + + if (this.isModuleInstalled('admin', 'documents')) { + modJs.subModJsList.tabEmployeeDocumentSubTab = new EmployeeSubDocumentAdapter('EmployeeDocument', 'EmployeeDocumentSubTab', { employee: data.id }); + modJs.subModJsList.tabEmployeeDocumentSubTab.parent = this; + } + for (const prop in modJs.subModJsList) { + if (modJs.subModJsList.hasOwnProperty(prop)) { + modJs.subModJsList[prop].setTranslationsSubModules(this.translations); + modJs.subModJsList[prop].setPermissions(this.permissions); + modJs.subModJsList[prop].setFieldTemplates(this.fieldTemplates); + modJs.subModJsList[prop].setTemplates(this.templates); + modJs.subModJsList[prop].setCustomTemplates(this.customTemplates); + modJs.subModJsList[prop].setEmailTemplates(this.emailTemplates); + modJs.subModJsList[prop].setUser(this.user); + modJs.subModJsList[prop].initFieldMasterData(); + modJs.subModJsList[prop].setBaseUrl(this.baseUrl); + modJs.subModJsList[prop].setCurrentProfile(this.currentProfile); + modJs.subModJsList[prop].setInstanceId(this.instanceId); + modJs.subModJsList[prop].setGoogleAnalytics(ga); + modJs.subModJsList[prop].setNoJSONRequests(this.noJSONRequests); + } + } + + modJs.subModJsList.tabEmployeeSkillSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeSkillSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeSkillSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeSkillSubTab.get([]); + + modJs.subModJsList.tabEmployeeEducationSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeEducationSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeEducationSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeEducationSubTab.get([]); + + modJs.subModJsList.tabEmployeeCertificationSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeCertificationSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeCertificationSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeCertificationSubTab.get([]); + + modJs.subModJsList.tabEmployeeLanguageSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeLanguageSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeLanguageSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeLanguageSubTab.get([]); + + modJs.subModJsList.tabEmployeeDependentSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeDependentSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeDependentSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeDependentSubTab.get([]); + + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeEmergencyContactSubTab.get([]); + + if (this.isModuleInstalled('admin', 'documents')) { + modJs.subModJsList.tabEmployeeDocumentSubTab.setShowFormOnPopup(true); + modJs.subModJsList.tabEmployeeDocumentSubTab.setShowAddNew(false); + modJs.subModJsList.tabEmployeeDocumentSubTab.setShowCancel(false); + modJs.subModJsList.tabEmployeeDocumentSubTab.get([]); + } + + $('#subModTab a').off().on('click', function (e) { + e.preventDefault(); + $(this).tab('show'); + }); + } + + + deleteProfileImage(empId) { + const req = { id: empId }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'modEmployeeDeleteProfileImageCallBack'; + callBackData.callBackFail = 'modEmployeeDeleteProfileImageCallBack'; + + this.customAction('deleteProfileImage', 'modules=employees', reqJson, callBackData); + } + + modEmployeeDeleteProfileImageCallBack(data) { + // top.location.href = top.location.href; + } +} + +/* + * Terminated Employee + */ + +class TerminatedEmployeeAdapter extends EmployeeAdapter { + getDataMapping() { + return [ + 'id', + 'image', + 'employee_id', + 'first_name', + 'last_name', + 'mobile_phone', + 'department', + 'gender', + 'supervisor', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: '', bSortable: false }, + { sTitle: 'Employee Number' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Mobile' }, + { sTitle: 'Department' }, + { sTitle: 'Gender' }, + { sTitle: 'Supervisor' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['nationality', { label: 'Nationality', type: 'select2', 'remote-source': ['Nationality', 'id', 'name'] }], + ['birthday', { label: 'Date of Birth', type: 'date', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['marital_status', { label: 'Marital Status', type: 'select', source: [['Married', 'Married'], ['Single', 'Single'], ['Divorced', 'Divorced'], ['Widowed', 'Widowed'], ['Other', 'Other']] }], + ['ssn_num', { label: 'SSN/NRIC', type: 'text', validation: 'none' }], + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + /* [ "driving_license_exp_date", {"label":"License Exp Date","type":"date","validation":"none"}], */ + ['employment_status', { label: 'Employment Status', type: 'select2', 'remote-source': ['EmploymentStatus', 'id', 'name'] }], + ['job_title', { label: 'Job Title', type: 'select2', 'remote-source': ['JobTitle', 'id', 'name'] }], + ['pay_grade', { + label: 'Pay Grade', type: 'select2', 'allow-null': true, 'remote-source': ['PayGrade', 'id', 'name'], + }], + ['work_station_id', { label: 'Work Station Id', type: 'text', validation: 'none' }], + ['address1', { label: 'Address Line 1', type: 'text', validation: 'none' }], + ['address2', { label: 'Address Line 2', type: 'text', validation: 'none' }], + ['city', { label: 'City', type: 'text', validation: 'none' }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ['province', { + label: 'Province', type: 'select2', 'allow-null': true, 'remote-source': ['Province', 'id', 'name'], + }], + ['postal_code', { label: 'Postal/Zip Code', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['work_email', { label: 'Work Email', type: 'text', validation: 'emailOrEmpty' }], + ['private_email', { label: 'Private Email', type: 'text', validation: 'emailOrEmpty' }], + ['joined_date', { label: 'Joined Date', type: 'date', validation: '' }], + ['confirmation_date', { label: 'Confirmation Date', type: 'date', validation: 'none' }], + ['termination_date', { label: 'Termination Date', type: 'date', validation: 'none' }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['notes', { + label: 'Notes', + type: 'datagroup', + form: [ + ['note', { label: 'Note', type: 'textarea', validation: '' }], + ], + html: '
    #_delete_##_edit_#Date: #_date_#
    #_note_#
    ', + validation: 'none', + 'sort-function': function (a, b) { + const t1 = Date.parse(a.date).getTime(); + const t2 = Date.parse(b.date).getTime(); + + return (t1 < t2); + }, + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + data.date = new Date().toString('d-MMM-yyyy hh:mm tt'); + res.params = data; + return res; + }, + + }], + ]; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'null-label': 'Anyone', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getActionButtonsHtml(id) { + // eslint-disable-next-line max-len + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + download(id) { + const params = { t: 'ArchivedEmployee', sa: 'downloadArchivedEmployee', mod: 'admin=employees' }; + params.req = JSON.stringify({ id }); + const downloadUrl = modJs.getCustomActionUrl('ca', params); + window.open(downloadUrl, '_blank'); + } +} + + +/* + * Archived Employee + */ + +class ArchivedEmployeeAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee_id', + 'first_name', + 'last_name', + 'work_email', + 'department', + 'gender', + 'supervisor', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'Employee Number' }, + { sTitle: 'First Name' }, + { sTitle: 'Last Name' }, + { sTitle: 'Work Email' }, + { sTitle: 'Department' }, + { sTitle: 'Gender' }, + { sTitle: 'Supervisor' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['employee_id', { label: 'Employee Number', type: 'text', validation: '' }], + ['first_name', { label: 'First Name', type: 'text', validation: '' }], + ['middle_name', { label: 'Middle Name', type: 'text', validation: 'none' }], + ['last_name', { label: 'Last Name', type: 'text', validation: '' }], + ['gender', { label: 'Gender', type: 'select', source: [['Male', 'Male'], ['Female', 'Female']] }], + ['ssn_num', { label: 'SSN/NRIC', type: 'text', validation: 'none' }], + ['nic_num', { label: 'NIC', type: 'text', validation: 'none' }], + ['other_id', { label: 'Other ID', type: 'text', validation: 'none' }], + ['driving_license', { label: 'Driving License No', type: 'text', validation: 'none' }], + ['department', { label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'] }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getFilters() { + return [ + ['job_title', { + label: 'Job Title', type: 'select2', 'allow-null': true, 'null-label': 'All Job Titles', 'remote-source': ['JobTitle', 'id', 'name'], + }], + ['department', { + label: 'Department', type: 'select2', 'allow-null': true, 'null-label': 'All Departments', 'remote-source': ['CompanyStructure', 'id', 'title'], + }], + ['supervisor', { + label: 'Supervisor', type: 'select2', 'allow-null': true, 'null-label': 'Anyone', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ]; + } + + getActionButtonsHtml(id) { + // eslint-disable-next-line max-len + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + download(id) { + const params = { t: 'ArchivedEmployee', sa: 'downloadArchivedEmployee', mod: 'admin=employees' }; + params.req = JSON.stringify({ id }); + const downloadUrl = modJs.getCustomActionUrl('ca', params); + window.open(downloadUrl, '_blank'); + } +} + + +/* + * ========================================================== + */ + + +class EmployeeSkillAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'skill_id', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Skill' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'remote-source': ['Skill', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: '' }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['skill_id', { + label: 'Skill', type: 'select2', 'allow-null': true, 'null-label': 'All Skills', 'remote-source': ['Skill', 'id', 'name'], + }], + + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeEducationAdapter + */ + +class EmployeeEducationAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'education_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Qualification' }, + { sTitle: 'Institute' }, + { sTitle: 'Start Date' }, + { sTitle: 'Completed On' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': false, 'remote-source': ['Education', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Start Date', type: 'date', validation: 'none' }], + ['date_end', { label: 'Completed On', type: 'date', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['education_id', { + label: 'Qualification', type: 'select2', 'allow-null': true, 'null-label': 'All Qualifications', 'remote-source': ['Education', 'id', 'name'], + }], + + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeCertificationAdapter + */ + +class EmployeeCertificationAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'certification_id', + 'institute', + 'date_start', + 'date_end', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Certification' }, + { sTitle: 'Institute' }, + { sTitle: 'Granted On' }, + { sTitle: 'Valid Thru' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': false, 'remote-source': ['Certification', 'id', 'name'], + }], + ['institute', { label: 'Institute', type: 'text', validation: '' }], + ['date_start', { label: 'Granted On', type: 'date', validation: 'none' }], + ['date_end', { label: 'Valid Thru', type: 'date', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['certification_id', { + label: 'Certification', type: 'select2', 'allow-null': true, 'null-label': 'All Certifications', 'remote-source': ['Certification', 'id', 'name'], + }], + + ]; + } + + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeLanguageAdapter + */ + +class EmployeeLanguageAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'language_id', + 'reading', + 'speaking', + 'writing', + 'understanding', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Language' }, + { sTitle: 'Reading' }, + { sTitle: 'Speaking' }, + { sTitle: 'Writing' }, + { sTitle: 'Understanding' }, + ]; + } + + getFormFields() { + const compArray = [['Elementary Proficiency', 'Elementary Proficiency'], + ['Limited Working Proficiency', 'Limited Working Proficiency'], + ['Professional Working Proficiency', 'Professional Working Proficiency'], + ['Full Professional Proficiency', 'Full Professional Proficiency'], + ['Native or Bilingual Proficiency', 'Native or Bilingual Proficiency']]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': false, 'remote-source': ['Language', 'id', 'name'], + }], + ['reading', { label: 'Reading', type: 'select', source: compArray }], + ['speaking', { label: 'Speaking', type: 'select', source: compArray }], + ['writing', { label: 'Writing', type: 'select', source: compArray }], + ['understanding', { label: 'Understanding', type: 'select', source: compArray }], + ]; + } + + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['language_id', { + label: 'Language', type: 'select2', 'allow-null': true, 'null-label': 'All Languages', 'remote-source': ['Language', 'id', 'name'], + }], + + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/** + * EmployeeDependentAdapter + */ + + +class EmployeeDependentAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'dob', + 'id_number', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Date of Birth' }, + { sTitle: 'Id Number' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'select', source: [['Child', 'Child'], ['Spouse', 'Spouse'], ['Parent', 'Parent'], ['Other', 'Other']] }], + ['dob', { label: 'Date of Birth', type: 'date', validation: '' }], + ['id_number', { label: 'Id Number', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/* + * EmergencyContactAdapter + */ + + +class EmergencyContactAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'name', + 'relationship', + 'home_phone', + 'work_phone', + 'mobile_phone', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Name' }, + { sTitle: 'Relationship' }, + { sTitle: 'Home Phone' }, + { sTitle: 'Work Phone' }, + { sTitle: 'Mobile Phone' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['relationship', { label: 'Relationship', type: 'text', validation: 'none' }], + ['home_phone', { label: 'Home Phone', type: 'text', validation: 'none' }], + ['work_phone', { label: 'Work Phone', type: 'text', validation: 'none' }], + ['mobile_phone', { label: 'Mobile Phone', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +/* + * EmployeeImmigrationAdapter + */ + + +class EmployeeImmigrationAdapter extends SubProfileEnabledAdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'doc_number', + 'issued', + 'expiry', + 'status', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document', sClass: 'columnMain' }, + { sTitle: 'Number' }, + { sTitle: 'Issued Date' }, + { sTitle: 'Expiry Date' }, + { sTitle: 'Status' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['document', { label: 'Document', type: 'select2', source: [['Passport', 'Passport'], ['Visa', 'Visa']] }], + ['doc_number', { label: 'Number', type: 'text', validation: '' }], + ['issued', { label: 'Issued Date', type: 'date', validation: '' }], + ['expiry', { label: 'Expiry Date', type: 'date', validation: '' }], + ['status', { label: 'Status', type: 'text', validation: 'none' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ]; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + +/** + * EmployeeDocumentAdapter + */ + +class EmployeeDocumentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'details', + 'date_added', + 'status', + 'attachment', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document' }, + { sTitle: 'Details' }, + { sTitle: 'Date Added' }, + { sTitle: 'Status' }, + { sTitle: 'Attachment', bVisible: false }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['Document', 'id', 'name'] }], + ['date_added', { label: 'Date Added', type: 'date', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } + + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_attachment_/g, data[6]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + isSubProfileTable() { + return this.user.user_level !== 'Admin'; + } +} + + +module.exports = { + EmployeeAdapter, + TerminatedEmployeeAdapter, + ArchivedEmployeeAdapter, + EmployeeSkillAdapter, + EmployeeEducationAdapter, + EmployeeCertificationAdapter, + EmployeeLanguageAdapter, + EmployeeDependentAdapter, + EmergencyContactAdapter, + EmployeeImmigrationAdapter, + EmployeeSubSkillsAdapter, + EmployeeSubEducationAdapter, + EmployeeSubCertificationAdapter, + EmployeeSubLanguageAdapter, + EmployeeSubDependentAdapter, + EmployeeSubEmergencyContactAdapter, + EmployeeSubDocumentAdapter, + EmployeeDocumentAdapter, +}; diff --git a/web/admin/src/fieldnames/index.js b/web/admin/src/fieldnames/index.js new file mode 100644 index 00000000..07a711da --- /dev/null +++ b/web/admin/src/fieldnames/index.js @@ -0,0 +1,4 @@ +import { FieldNameAdapter, CustomFieldAdapter } from './lib'; + +window.FieldNameAdapter = FieldNameAdapter; +window.CustomFieldAdapter = CustomFieldAdapter; diff --git a/web/admin/src/fieldnames/lib.js b/web/admin/src/fieldnames/lib.js new file mode 100644 index 00000000..5edc0e67 --- /dev/null +++ b/web/admin/src/fieldnames/lib.js @@ -0,0 +1,47 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import CustomFieldAdapter from '../../../api/CustomFieldAdapter'; + +/** + * FieldNameAdapter + */ + +class FieldNameAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'textOrig', + 'textMapped', + 'display', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Original Text' }, + { sTitle: 'Mapped Text' }, + { sTitle: 'Display Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['type', { label: 'Type', type: 'placeholder', validation: '' }], + ['name', { label: 'Name', type: 'placeholder', validation: '' }], + ['textOrig', { label: 'Original Text', type: 'placeholder', validation: '' }], + ['textMapped', { label: 'Mapped Text', type: 'text', validation: '' }], + ['display', { label: 'Display Status', type: 'select', source: [['Form', 'Show'], ['Hidden', 'Hidden']] }], + ]; + } +} + + +module.exports = { FieldNameAdapter, CustomFieldAdapter }; diff --git a/web/admin/src/jobs/index.js b/web/admin/src/jobs/index.js new file mode 100644 index 00000000..22cfebc7 --- /dev/null +++ b/web/admin/src/jobs/index.js @@ -0,0 +1,5 @@ +import { JobTitleAdapter, PayGradeAdapter, EmploymentStatusAdapter } from './lib'; + +window.JobTitleAdapter = JobTitleAdapter; +window.PayGradeAdapter = PayGradeAdapter; +window.EmploymentStatusAdapter = EmploymentStatusAdapter; diff --git a/web/admin/src/jobs/lib.js b/web/admin/src/jobs/lib.js new file mode 100644 index 00000000..23a2cc58 --- /dev/null +++ b/web/admin/src/jobs/lib.js @@ -0,0 +1,124 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * JobTitleAdapter + */ + +class JobTitleAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Job Title Code', type: 'text' }], + ['name', { label: 'Job Title', type: 'text' }], + ['description', { label: 'Description', type: 'textarea' }], + ['specification', { label: 'Specification', type: 'textarea' }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/jobdetails/'; + } +} + + +/** + * PayGradeAdapter + */ + +class PayGradeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'currency', + 'min_salary', + 'max_salary', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Currency' }, + { sTitle: 'Min Salary' }, + { sTitle: 'Max Salary' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Pay Grade Name', type: 'text' }], + ['currency', { label: 'Currency', type: 'select2', 'remote-source': ['CurrencyType', 'code', 'name'] }], + ['min_salary', { label: 'Min Salary', type: 'text', validation: 'float' }], + ['max_salary', { label: 'Max Salary', type: 'text', validation: 'float' }], + ]; + } + + doCustomValidation(params) { + try { + if (parseFloat(params.min_salary) > parseFloat(params.max_salary)) { + return 'Min Salary should be smaller than Max Salary'; + } + } catch (e) { + // D/N + } + return null; + } +} + + +/** + * EmploymentStatusAdapter + */ + +class EmploymentStatusAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Employment Status', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + + +module.exports = { JobTitleAdapter, PayGradeAdapter, EmploymentStatusAdapter }; diff --git a/web/admin/src/loans/index.js b/web/admin/src/loans/index.js new file mode 100644 index 00000000..82afb258 --- /dev/null +++ b/web/admin/src/loans/index.js @@ -0,0 +1,7 @@ +import { + CompanyLoanAdapter, + EmployeeCompanyLoanAdapter, +} from './lib'; + +window.CompanyLoanAdapter = CompanyLoanAdapter; +window.EmployeeCompanyLoanAdapter = EmployeeCompanyLoanAdapter; diff --git a/web/admin/src/loans/lib.js b/web/admin/src/loans/lib.js new file mode 100644 index 00000000..cf71f83b --- /dev/null +++ b/web/admin/src/loans/lib.js @@ -0,0 +1,101 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; + +/** + * CompanyLoanAdapter + */ + +class CompanyLoanAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + + +/* + * EmployeeCompanyLoanAdapter + */ + +class EmployeeCompanyLoanAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'loan', + 'start_date', + 'period_months', + 'currency', + 'amount', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Loan Type' }, + { sTitle: 'Loan Start Date' }, + { sTitle: 'Loan Period (Months)' }, + { sTitle: 'Currency' }, + { sTitle: 'Amount' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['loan', { label: 'Loan Type', type: 'select', 'remote-source': ['CompanyLoan', 'id', 'name'] }], + ['start_date', { label: 'Loan Start Date', type: 'date', validation: '' }], + ['last_installment_date', { label: 'Last Installment Date', type: 'date', validation: 'none' }], + ['period_months', { label: 'Loan Period (Months)', type: 'text', validation: 'number' }], + ['currency', { label: 'Currency', type: 'select2', 'remote-source': ['CurrencyType', 'id', 'name'] }], + ['amount', { label: 'Loan Amount', type: 'text', validation: 'float' }], + ['monthly_installment', { label: 'Monthly Installment', type: 'text', validation: 'float' }], + ['status', { label: 'Status', type: 'select', source: [['Approved', 'Approved'], ['Paid', 'Paid'], ['Suspended', 'Suspended']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': true, 'null-label': 'All Employees', 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['loan', { + label: 'Loan Type', type: 'select', 'allow-null': true, 'null-label': 'All Loan Types', 'remote-source': ['CompanyLoan', 'id', 'name'], + }], + + ]; + } +} + +module.exports = { + CompanyLoanAdapter, + EmployeeCompanyLoanAdapter, +}; diff --git a/web/admin/src/metadata/index.js b/web/admin/src/metadata/index.js new file mode 100644 index 00000000..82af59b6 --- /dev/null +++ b/web/admin/src/metadata/index.js @@ -0,0 +1,15 @@ +import { + CountryAdapter, + ProvinceAdapter, + CurrencyTypeAdapter, + NationalityAdapter, + ImmigrationStatusAdapter, + EthnicityAdapter, +} from './lib'; + +window.CountryAdapter = CountryAdapter; +window.ProvinceAdapter = ProvinceAdapter; +window.CurrencyTypeAdapter = CurrencyTypeAdapter; +window.NationalityAdapter = NationalityAdapter; +window.ImmigrationStatusAdapter = ImmigrationStatusAdapter; +window.EthnicityAdapter = EthnicityAdapter; diff --git a/web/admin/src/metadata/lib.js b/web/admin/src/metadata/lib.js new file mode 100644 index 00000000..789310a1 --- /dev/null +++ b/web/admin/src/metadata/lib.js @@ -0,0 +1,142 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import IdNameAdapter from '../../../api/IdNameAdapter'; +/** + * CountryAdapter + */ + +class CountryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * ProvinceAdapter + */ + +class ProvinceAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + 'country', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + { sTitle: 'Country' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + ]; + } + + getFilters() { + return [ + ['country', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }], + + ]; + } +} + +/** + * CurrencyTypeAdapter + */ + +class CurrencyTypeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * NationalityAdapter + */ + +class NationalityAdapter extends IdNameAdapter { + +} + +/** + * ImmigrationStatusAdapter + */ + +class ImmigrationStatusAdapter extends IdNameAdapter { + +} + + +/** + * EthnicityAdapter + */ + +class EthnicityAdapter extends IdNameAdapter { + +} + +module.exports = { + CountryAdapter, + ProvinceAdapter, + CurrencyTypeAdapter, + NationalityAdapter, + ImmigrationStatusAdapter, + EthnicityAdapter, +}; diff --git a/web/admin/src/modules/index.js b/web/admin/src/modules/index.js new file mode 100644 index 00000000..e9b5c349 --- /dev/null +++ b/web/admin/src/modules/index.js @@ -0,0 +1,4 @@ +import { ModuleAdapter, UsageAdapter } from './lib'; + +window.ModuleAdapter = ModuleAdapter; +window.UsageAdapter = UsageAdapter; diff --git a/web/admin/src/modules/lib.js b/web/admin/src/modules/lib.js new file mode 100644 index 00000000..c99f3b3d --- /dev/null +++ b/web/admin/src/modules/lib.js @@ -0,0 +1,133 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +import AdapterBase from '../../../api/AdapterBase'; +/** + * ModuleAdapter + */ + +class ModuleAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'label', + 'menu', + 'mod_group', + 'mod_order', + 'status', + 'version', + 'update_path', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Menu', bVisible: false }, + { sTitle: 'Group' }, + { sTitle: 'Order' }, + { sTitle: 'Status' }, + { sTitle: 'Version', bVisible: false }, + { sTitle: 'Path', bVisible: false }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['label', { label: 'Label', type: 'text', validation: '' }], + ['status', { label: 'Status', type: 'select', source: [['Enabled', 'Enabled'], ['Disabled', 'Disabled']] }], + ['user_levels', { label: 'User Levels', type: 'select2multi', source: [['Admin', 'Admin'], ['Manager', 'Manager'], ['Employee', 'Employee'], ['Other', 'Other']] }], + ['user_roles', { label: 'User Roles', type: 'select2multi', 'remote-source': ['UserRole', 'id', 'name'] }], + ]; + } + + + getActionButtonsHtml(id, data) { + const nonEditableFields = {}; + nonEditableFields['admin_Company Structure'] = 1; + nonEditableFields.admin_Employees = 1; + nonEditableFields['admin_Job Details Setup'] = 1; + nonEditableFields.admin_Leaves = 1; + nonEditableFields['admin_Manage Modules'] = 1; + nonEditableFields.admin_Projects = 1; + nonEditableFields.admin_Qualifications = 1; + nonEditableFields.admin_Settings = 1; + nonEditableFields.admin_Users = 1; + nonEditableFields.admin_Upgrade = 1; + nonEditableFields.admin_Dashboard = 1; + + nonEditableFields['user_Basic Information'] = 1; + nonEditableFields.user_Dashboard = 1; + + if (nonEditableFields[`${data[3]}_${data[1]}`] === 1) { + return ''; + } + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + + +/** + * UsageAdapter + */ + +class UsageAdapter extends AdapterBase { + getDataMapping() { + return []; + } + + getHeaders() { + return []; + } + + getFormFields() { + return []; + } + + + get(callBackData) { + + } + + saveUsage() { + const object = {}; + const arr = []; + $('.module-check').each(function () { + if ($(this).is(':checked')) { + arr.push($(this).val()); + } + }); + + if (arr.length === 0) { + alert('Please select one or more module groups'); + return; + } + + object.groups = arr.join(','); + + const reqJson = JSON.stringify(object); + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'getInitDataSuccessCallBack'; + callBackData.callBackFail = 'getInitDataFailCallBack'; + + this.customAction('saveUsage', 'admin=modules', reqJson, callBackData); + } + + + saveUsageSuccessCallBack(data) { + + } + + saveUsageFailCallBack(callBackData) { + + } +} + +module.exports = { ModuleAdapter, UsageAdapter }; diff --git a/web/admin/src/overtime/index.js b/web/admin/src/overtime/index.js new file mode 100644 index 00000000..25a00705 --- /dev/null +++ b/web/admin/src/overtime/index.js @@ -0,0 +1,7 @@ +import { + OvertimeCategoryAdapter, + EmployeeOvertimeAdminAdapter, +} from './lib'; + +window.OvertimeCategoryAdapter = OvertimeCategoryAdapter; +window.EmployeeOvertimeAdminAdapter = EmployeeOvertimeAdminAdapter; diff --git a/web/admin/src/overtime/lib.js b/web/admin/src/overtime/lib.js new file mode 100644 index 00000000..944a9074 --- /dev/null +++ b/web/admin/src/overtime/lib.js @@ -0,0 +1,100 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import ApproveAdminAdapter from '../../../api/ApproveAdminAdapter'; + +/** + * OvertimeCategoryAdapter + */ + +class OvertimeCategoryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * EmployeeOvertimeAdminAdapter + */ + + +class EmployeeOvertimeAdminAdapter extends ApproveAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'OvertimeRequest'; + this.itemNameLower = 'overtimerequest'; + this.modulePathName = 'overtime'; + } + + getDataMapping() { + return [ + 'id', + 'employee', + 'category', + 'start_time', + 'end_time', + 'project', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Category' }, + { sTitle: 'Start Time' }, + { sTitle: 'End Time' }, + { sTitle: 'Project' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['category', { + label: 'Category', type: 'select2', 'allow-null': false, 'remote-source': ['OvertimeCategory', 'id', 'name'], + }], + ['start_time', { label: 'Start Time', type: 'datetime', validation: '' }], + ['end_time', { label: 'End Time', type: 'datetime', validation: '' }], + ['project', { + label: 'Project', type: 'select2', 'allow-null': true, 'null=label': 'none', 'remote-source': ['Project', 'id', 'name'], + }], + ['notes', { label: 'Notes', type: 'textarea', validation: 'none' }], + ]; + } +} + +module.exports = { + OvertimeCategoryAdapter, + EmployeeOvertimeAdminAdapter, +}; diff --git a/web/admin/src/payroll/index.js b/web/admin/src/payroll/index.js new file mode 100644 index 00000000..943a7dcf --- /dev/null +++ b/web/admin/src/payroll/index.js @@ -0,0 +1,21 @@ +import { + PaydayAdapter, + PayrollAdapter, + PayrollDataAdapter, + PayrollColumnAdapter, + PayrollColumnTemplateAdapter, + PayrollEmployeeAdapter, + DeductionAdapter, + DeductionGroupAdapter, + PayslipTemplateAdapter, +} from './lib'; + +window.PaydayAdapter = PaydayAdapter; +window.PayrollAdapter = PayrollAdapter; +window.PayrollDataAdapter = PayrollDataAdapter; +window.PayrollColumnAdapter = PayrollColumnAdapter; +window.PayrollColumnTemplateAdapter = PayrollColumnTemplateAdapter; +window.PayrollEmployeeAdapter = PayrollEmployeeAdapter; +window.DeductionAdapter = DeductionAdapter; +window.DeductionGroupAdapter = DeductionGroupAdapter; +window.PayslipTemplateAdapter = PayslipTemplateAdapter; diff --git a/web/admin/src/payroll/lib.js b/web/admin/src/payroll/lib.js new file mode 100644 index 00000000..ea8ee13e --- /dev/null +++ b/web/admin/src/payroll/lib.js @@ -0,0 +1,631 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global modJs, modJsList */ +import AdapterBase from '../../../api/AdapterBase'; +import TableEditAdapter from '../../../api/TableEditAdapter'; + +/** + * PaydayAdapter + */ + +class PaydayAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Select Pay Frequency' }, + ]; + } + + getFormFields() { + return [ + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } + + getAddNewLabel() { + return 'Run Payroll'; + } + + createTable(elementId) { + $('#payday_all').off(); + super.createTable(elementId); + $('#payday_all').off().on('click', function () { + if ($(this).is(':checked')) { + $('.paydayCheck').prop('checked', true); + } else { + $('.paydayCheck').prop('checked', false); + } + }); + } + + getActionButtonsHtml(id, data) { + const editButton = ''; + + let html = '
    _edit_
    '; + html = html.replace('_edit_', editButton); + + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + getActionButtonHeader() { + return { sTitle: '', sClass: 'center' }; + } +} + + +/** + * PayrollAdapter + */ + +class PayrollAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'pay_period', + 'department', + 'date_start', + 'date_end', + 'status', + + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Pay Frequency' }, + { sTitle: 'Department' }, + { sTitle: 'Date Start' }, + { sTitle: 'Date End' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['pay_period', { + label: 'Pay Frequency', type: 'select', 'remote-source': ['PayFrequency', 'id', 'name'], sort: 'none', + }], + ['deduction_group', { + label: 'Calculation Group', type: 'select', 'remote-source': ['DeductionGroup', 'id', 'name'], sort: 'none', + }], + ['payslipTemplate', { label: 'Payslip Template', type: 'select', 'remote-source': ['PayslipTemplate', 'id', 'name'] }], + ['department', { + label: 'Department', type: 'select2', 'remote-source': ['CompanyStructure', 'id', 'title'], sort: 'none', + }], + ['date_start', { label: 'Start Date', type: 'date', validation: '' }], + ['date_end', { label: 'End Date', type: 'date', validation: '' }], + // [ "column_template", {"label":"Report Column Template","type":"select","remote-source":["PayrollColumnTemplate","id","name"]}], + ['columns', { label: 'Payroll Columns', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ['status', { + label: 'Status', type: 'select', source: [['Draft', 'Draft'], ['Completed', 'Completed']], sort: 'none', + }], + ]; + } + + postRenderForm(object, $tempDomObj) { + if (object != null && object !== undefined && object.id !== undefined && object.id != null) { + $tempDomObj.find('#pay_period').attr('disabled', 'disabled'); + $tempDomObj.find('#department').attr('disabled', 'disabled'); + // $tempDomObj.find("#date_start").attr('disabled','disabled'); + // $tempDomObj.find("#date_end").attr('disabled','disabled'); + // $tempDomObj.find("#column_template").attr('disabled','disabled'); + } + } + + process(id, status) { + // eslint-disable-next-line no-global-assign + modJs = modJsList.tabPayrollData; + modJs.setCurrentPayroll(id); + $('#Payroll').hide(); + $('#PayrollData').show(); + $('#PayrollDataButtons').show(); + + if (status === 'Completed') { + $('.completeBtnTable').hide(); + $('.saveBtnTable').hide(); + } else { + $('.completeBtnTable').show(); + $('.saveBtnTable').show(); + } + + modJs.get([]); + } + + + getActionButtonsHtml(id, data) { + const editButton = ''; + const processButton = ''; + const deleteButton = ''; + const cloneButton = ''; + + let html = '
    _edit__process__clone__delete_
    '; + + + if (this.showAddNew) { + html = html.replace('_clone_', cloneButton); + } else { + html = html.replace('_clone_', ''); + } + + if (this.showDelete) { + html = html.replace('_delete_', deleteButton); + } else { + html = html.replace('_delete_', ''); + } + + if (this.showEdit) { + html = html.replace('_edit_', editButton); + } else { + html = html.replace('_edit_', ''); + } + + html = html.replace('_process_', processButton); + + + html = html.replace(/_id_/g, id); + html = html.replace(/_status_/g, data[6]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + get(callBackData) { + $('#PayrollData').hide(); + $('#PayrollForm').hide(); + $('#PayrollDataButtons').hide(); + $('#Payroll').show(); + modJsList.tabPayrollData.setCurrentPayroll(null); + super.get(callBackData); + } +} + + +/** + * PayrollDataAdapter + */ + +class PayrollDataAdapter extends TableEditAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.cellDataUpdates = {}; + this.payrollId = null; + } + + validateCellValue(element, evt, newValue) { + modJs.addCellDataUpdate(element.data('colId'), element.data('rowId'), newValue); + return true; + } + + setCurrentPayroll(val) { + this.payrollId = val; + } + + + addAdditionalRequestData(type, req) { + if (type === 'updateData') { + req.payrollId = this.payrollId; + } else if (type === 'updateAllData') { + req.payrollId = this.payrollId; + } else if (type === 'getAllData') { + req.payrollId = this.payrollId; + } + + return req; + } + + modifyCSVHeader(header) { + header.unshift(''); + return header; + } + + getCSVData() { + let csv = ''; + + for (let i = 0; i < this.csvData.length; i++) { + csv += this.csvData[i].join(','); + if (i < this.csvData.length - 1) { + csv += '\r\n'; + } + } + + return csv; + } + + downloadPayroll() { + const element = document.createElement('a'); + element.setAttribute('href', `data:text/plain;charset=utf-8,${encodeURIComponent(this.getCSVData())}`); + element.setAttribute('download', `payroll_${this.payrollId}.csv`); + + element.style.display = 'none'; + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } +} + + +/** + * PayrollColumnAdapter + */ + +class PayrollColumnAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'colorder', + 'calculation_hook', + 'deduction_group', + 'editable', + 'enabled', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Column Order' }, + { sTitle: 'Calculation Method' }, + { sTitle: 'Calculation Group' }, + { sTitle: 'Editable' }, + { sTitle: 'Enabled' }, + ]; + } + + getFormFields() { + const fucntionColumnList = ['calculation_columns', { + label: 'Calculation Columns', + type: 'datagroup', + form: [ + ['name', { label: 'Name', type: 'text', validation: '' }], + ['column', { label: 'Column', type: 'select2', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ], + html: '
    #_delete_##_edit_#
    #_renderFunction_#
    ', + validation: 'none', + render(item) { + const output = `Variable:${item.name}`; + return output; + }, + + }]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['calculation_hook', { + label: 'Predefined Calculations', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['CalculationHook', 'code', 'name'], + }], + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'Common', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + ['salary_components', { label: 'Salary Components', type: 'select2multi', 'remote-source': ['SalaryComponent', 'id', 'name'] }], + ['deductions', { label: 'Calculation Method', type: 'select2multi', 'remote-source': ['Deduction', 'id', 'name'] }], + ['add_columns', { label: 'Columns to Add', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ['sub_columns', { label: 'Columns to Subtract', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ['colorder', { label: 'Column Order', type: 'text', validation: 'number' }], + ['editable', { label: 'Editable', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], + ['enabled', { label: 'Enabled', type: 'select', source: [['Yes', 'Yes'], ['No', 'No']] }], + ['default_value', { label: 'Default Value', type: 'text', validation: '' }], + fucntionColumnList, + ['calculation_function', { label: 'Function', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'Any', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + ]; + } +} + + +/** + * PayrollColumnTemplateAdapter + */ + +class PayrollColumnTemplateAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: true }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['columns', { label: 'Payroll Columns', type: 'select2multi', 'remote-source': ['PayrollColumn', 'id', 'name'] }], + ]; + } +} + + +/* + * PayrollEmployeeAdapter + */ + +class PayrollEmployeeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'pay_frequency', + 'deduction_group', + 'currency', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Pay Frequency' }, + { sTitle: 'Calculation Group' }, + { sTitle: 'Currency' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['pay_frequency', { label: 'Pay Frequency', type: 'select2', 'remote-source': ['PayFrequency', 'id', 'name'] }], + ['currency', { label: 'Currency', type: 'select2', 'remote-source': ['CurrencyType', 'id', 'code'] }], + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + ['deduction_exemptions', { + label: 'Calculation Exemptions', type: 'select2multi', 'remote-source': ['Deduction', 'id', 'name'], validation: 'none', + }], + ['deduction_allowed', { + label: 'Calculations Assigned', type: 'select2multi', 'remote-source': ['Deduction', 'id', 'name'], validation: 'none', + }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ]; + } +} + + +/** + * DeductionAdapter + */ + +class DeductionAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'deduction_group', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Calculation Group' }, + ]; + } + + getFormFields() { + const rangeAmounts = ['rangeAmounts', { + label: 'Calculation Process', + type: 'datagroup', + form: [ + ['lowerCondition', { label: 'Lower Limit Condition', type: 'select', source: [['No Lower Limit', 'No Lower Limit'], ['gt', 'Greater than'], ['gte', 'Greater than or Equal']] }], + ['lowerLimit', { label: 'Lower Limit', type: 'text', validation: 'float' }], + ['upperCondition', { label: 'Upper Limit Condition', type: 'select', source: [['No Upper Limit', 'No Upper Limit'], ['lt', 'Less than'], ['lte', 'Less than or Equal']] }], + ['upperLimit', { label: 'Upper Limit', type: 'text', validation: 'float' }], + ['amount', { label: 'Value', type: 'text', validation: '' }], + ], + html: '
    #_delete_##_edit_#
    #_renderFunction_#
    ', + validation: 'none', + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + if (data.lowerCondition === 'No Lower Limit') { + data.lowerLimit = 0; + } + if (data.upperCondition === 'No Upper Limit') { + data.upperLimit = 0; + } + res.params = data; + return res; + }, + render(item) { + let output = ''; + const getSymbol = function (text) { + const map = {}; + map.gt = '>'; + map.gte = '>='; + map.lt = '<'; + map.lte = '<='; + + return map[text]; + }; + + if (item.lowerCondition !== 'No Lower Limit') { + output += `${item.lowerLimit} ${getSymbol(item.lowerCondition)} `; + } + + if (item.upperCondition !== 'No Upper Limit') { + output += ' and '; + output += `${getSymbol(item.upperCondition)} ${item.upperLimit} `; + } + if (output === '') { + return `Deduction is ${item.amount} for all ranges`; + } + return `If salary component ${output} deduction is ${item.amount}`; + }, + + }]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['componentType', { + label: 'Salary Component Type', type: 'select2multi', 'allow-null': true, 'remote-source': ['SalaryComponentType', 'id', 'name'], + }], + ['component', { + label: 'Salary Component', type: 'select2multi', 'allow-null': true, 'remote-source': ['SalaryComponent', 'id', 'name'], + }], + ['payrollColumn', { + label: 'Payroll Report Column', type: 'select2', 'allow-null': true, 'remote-source': ['PayrollColumn', 'id', 'name'], + }], + rangeAmounts, + ['deduction_group', { + label: 'Calculation Group', type: 'select2', 'allow-null': true, 'null-label': 'None', 'remote-source': ['DeductionGroup', 'id', 'name'], + }], + + ]; + } +} + + +/* + * DeductionGroupAdapter + */ + +class DeductionGroupAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['description', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + + +/* + * PayslipTemplateAdapter + */ + +class PayslipTemplateAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + const payslipFields = ['data', { + label: 'Payslip Fields', + type: 'datagroup', + form: [ + ['type', { + label: 'Type', type: 'select', sort: 'none', source: [['Payroll Column', 'Payroll Column'], ['Text', 'Text'], ['Company Name', 'Company Name'], ['Company Logo', 'Company Logo'], ['Separators', 'Separators']], + }], + ['payrollColumn', { + label: 'Payroll Column', type: 'select2', sort: 'none', 'allow-null': true, 'null-label': 'None', 'remote-source': ['PayrollColumn', 'id', 'name'], + }], + + ['label', { label: 'Label', type: 'text', validation: 'none' }], + ['text', { label: 'Text', type: 'textarea', validation: 'none' }], + ['status', { + label: 'Status', type: 'select', sort: 'none', source: [['Show', 'Show'], ['Hide', 'Hide']], + }], + ], + + // "html":'
    #_delete_##_edit_#
    Type#_type_#
    Label#_label_#
    Text#_text_#
    Font Size#_fontSize_#
    Font Style#_fontStyle_#
    Font Color#_fontColor_#
    Status#_status_#
    ', + html: '
    #_delete_##_edit_#
    #_type_# #_label_#
    #_text_#
    ', + validation: 'none', + 'custom-validate-function': function (data) { + const res = {}; + res.valid = true; + if (data.type === 'Payroll Column') { + if (data.payrollColumn === 'NULL') { + res.valid = false; + res.message = 'Please select payroll column'; + } else { + data.payrollColumn = 'NULL'; + } + } else if (data.type === 'Text') { + if (data.text === '') { + res.valid = false; + res.message = 'Text can not be empty'; + } + } + + res.params = data; + return res; + }, + }]; + + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + payslipFields, + ]; + } +} + + +module.exports = { + PaydayAdapter, + PayrollAdapter, + PayrollDataAdapter, + PayrollColumnAdapter, + PayrollColumnTemplateAdapter, + PayrollEmployeeAdapter, + DeductionAdapter, + DeductionGroupAdapter, + PayslipTemplateAdapter, +}; diff --git a/web/admin/src/permissions/index.js b/web/admin/src/permissions/index.js new file mode 100644 index 00000000..7ff67c96 --- /dev/null +++ b/web/admin/src/permissions/index.js @@ -0,0 +1,3 @@ +import { PermissionAdapter } from './lib'; + +window.PermissionAdapter = PermissionAdapter; diff --git a/web/admin/src/permissions/lib.js b/web/admin/src/permissions/lib.js new file mode 100644 index 00000000..766cc618 --- /dev/null +++ b/web/admin/src/permissions/lib.js @@ -0,0 +1,73 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * PermissionAdapter + */ + +class PermissionAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'user_level', + 'module_id', + 'permission', + 'value', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'User Level' }, + { sTitle: 'Module' }, + { sTitle: 'Permission' }, + { sTitle: 'Value' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['user_level', { label: 'User Level', type: 'placeholder', validation: 'none' }], + ['module_id', { label: 'Module', type: 'placeholder', 'remote-source': ['Module', 'id', 'menu+name'] }], + ['permission', { label: 'Permission', type: 'placeholder', validation: 'none' }], + ['value', { label: 'Value', type: 'text', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['module_id', { + label: 'Module', type: 'select2', 'allow-null': true, 'null-label': 'All Modules', 'remote-source': ['Module', 'id', 'menu+name'], + }], + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + getMetaFieldForRendering(fieldName) { + if (fieldName === 'value') { + return 'meta'; + } + return ''; + } + + + fillForm(object) { + super.fillForm(object); + $('#helptext').html(object.description); + } +} + +module.exports = { PermissionAdapter }; diff --git a/web/admin/src/projects/index.js b/web/admin/src/projects/index.js new file mode 100644 index 00000000..45f71baf --- /dev/null +++ b/web/admin/src/projects/index.js @@ -0,0 +1,9 @@ +import { + ClientAdapter, + ProjectAdapter, + EmployeeProjectAdapter, +} from './lib'; + +window.ClientAdapter = ClientAdapter; +window.ProjectAdapter = ProjectAdapter; +window.EmployeeProjectAdapter = EmployeeProjectAdapter; diff --git a/web/admin/src/projects/lib.js b/web/admin/src/projects/lib.js new file mode 100644 index 00000000..95139c63 --- /dev/null +++ b/web/admin/src/projects/lib.js @@ -0,0 +1,163 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * ClientAdapter + */ + +class ClientAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'details', + 'address', + 'contact_number', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + { sTitle: 'Address' }, + { sTitle: 'Contact Number' }, + ]; + } + + getFormFields() { + if (this.showSave) { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['address', { label: 'Address', type: 'textarea', validation: 'none' }], + ['contact_number', { label: 'Contact Number', type: 'text', validation: 'none' }], + ['contact_email', { label: 'Contact Email', type: 'text', validation: 'none' }], + ['company_url', { label: 'Company Url', type: 'text', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive']] }], + ['first_contact_date', { label: 'First Contact Date', type: 'date', validation: 'none' }], + ]; + } + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'placeholder' }], + ['details', { label: 'Details', type: 'placeholder', validation: 'none' }], + ['address', { label: 'Address', type: 'placeholder', validation: 'none' }], + ['contact_number', { label: 'Contact Number', type: 'placeholder', validation: 'none' }], + ['contact_email', { label: 'Contact Email', type: 'placeholder', validation: 'none' }], + ['company_url', { label: 'Company Url', type: 'placeholder', validation: 'none' }], + ['status', { label: 'Status', type: 'placeholder', source: [['Active', 'Active'], ['Inactive', 'Inactive']] }], + ['first_contact_date', { label: 'First Contact Date', type: 'placeholder', validation: 'none' }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/projects/'; + } +} + + +/** + * ProjectAdapter + */ + +class ProjectAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'client', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Client' }, + ]; + } + + getFormFields() { + if (this.showSave) { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['client', { + label: 'Client', type: 'select2', 'allow-null': true, 'remote-source': ['Client', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['On Hold', 'On Hold'], ['Completed', 'Completed'], ['Dropped', 'Dropped']] }], + ]; + } + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'placeholder' }], + ['client', { + label: 'Client', type: 'placeholder', 'allow-null': true, 'remote-source': ['Client', 'id', 'name'], + }], + ['details', { label: 'Details', type: 'placeholder', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['On Hold', 'On Hold'], ['Completed', 'Completed'], ['Dropped', 'Dropped']] }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/projects/'; + } +} + + +/* + * EmployeeProjectAdapter + */ + + +class EmployeeProjectAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'project', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Project' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['project', { label: 'Project', type: 'select2', 'remote-source': ['Project', 'id', 'name'] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/projects/'; + } +} + +module.exports = { + ClientAdapter, + ProjectAdapter, + EmployeeProjectAdapter, +}; diff --git a/web/admin/src/qualifications/index.js b/web/admin/src/qualifications/index.js new file mode 100644 index 00000000..847ec6de --- /dev/null +++ b/web/admin/src/qualifications/index.js @@ -0,0 +1,11 @@ +import { + SkillAdapter, + EducationAdapter, + CertificationAdapter, + LanguageAdapter, +} from './lib'; + +window.SkillAdapter = SkillAdapter; +window.EducationAdapter = EducationAdapter; +window.CertificationAdapter = CertificationAdapter; +window.LanguageAdapter = LanguageAdapter; diff --git a/web/admin/src/qualifications/lib.js b/web/admin/src/qualifications/lib.js new file mode 100644 index 00000000..1984de49 --- /dev/null +++ b/web/admin/src/qualifications/lib.js @@ -0,0 +1,140 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * SkillAdapter + */ + +class SkillAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } + + getHelpLink() { + return 'http://blog.icehrm.com/docs/qualifications/'; + } +} + + +/** + * EducationAdapter + */ + +class EducationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + + +/** + * CertificationAdapter + */ + +class CertificationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + + +/** + * LanguageAdapter + */ + +class LanguageAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Description' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text' }], + ['description', { label: 'Description', type: 'textarea', validation: '' }], + ]; + } +} + +module.exports = { + SkillAdapter, + EducationAdapter, + CertificationAdapter, + LanguageAdapter, +}; diff --git a/web/admin/src/reports/index.js b/web/admin/src/reports/index.js new file mode 100644 index 00000000..4ef2b125 --- /dev/null +++ b/web/admin/src/reports/index.js @@ -0,0 +1,4 @@ +import { ReportAdapter, ReportGenAdapter } from './lib'; + +window.ReportAdapter = ReportAdapter; +window.ReportGenAdapter = ReportGenAdapter; diff --git a/web/admin/src/reports/lib.js b/web/admin/src/reports/lib.js new file mode 100644 index 00000000..b96fc8fa --- /dev/null +++ b/web/admin/src/reports/lib.js @@ -0,0 +1,372 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +/* global SignaturePad, modJs */ +/* eslint-disable no-underscore-dangle */ + +import AdapterBase from '../../../api/AdapterBase'; + + +/** + * ReportAdapter + */ + + +class ReportAdapter extends AdapterBase { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this._construct(); + } + + _construct() { + this._formFileds = [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'label', validation: '' }], + ['parameters', { label: 'Parameters', type: 'fieldset', validation: 'none' }], + ]; + this.remoteFieldsExists = false; + } + + _initLocalFormFields() { + this._formFileds = [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'label', validation: '' }], + ['parameters', { label: 'Parameters', type: 'fieldset', validation: 'none' }], + ]; + } + + setRemoteFieldExists(val) { + this.remoteFieldsExists = val; + } + + getDataMapping() { + return [ + 'id', + 'icon', + 'name', + 'details', + 'parameters', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: '', bSortable: false, sWidth: '22px' }, + { sTitle: 'Name', sWidth: '30%' }, + { sTitle: 'Details' }, + { sTitle: 'Parameters', bVisible: false }, + ]; + } + + + getFormFields() { + return this._formFileds; + } + + processFormFieldsWithObject(object) { + const that = this; + this._initLocalFormFields(); + const len = this._formFileds.length; + const fieldIDsToDelete = []; + const fieldsToDelete = []; + this.remoteFieldsExists = false; + for (let i = 0; i < len; i++) { + if (this._formFileds[i][1].type === 'fieldset') { + const newFields = JSON.parse(object[this._formFileds[i][0]]); + fieldsToDelete.push(this._formFileds[i][0]); + newFields.forEach((entry) => { + that._formFileds.push(entry); + if (entry[1]['remote-source'] !== undefined && entry[1]['remote-source'] != null) { + that.remoteFieldsExists = true; + } + }); + } + } + + const tempArray = []; + that._formFileds.forEach((entry) => { + if (jQuery.inArray(entry[0], fieldsToDelete) < 0) { + tempArray.push(entry); + } + }); + + that._formFileds = tempArray; + } + + + renderForm(object) { + const that = this; + this.processFormFieldsWithObject(object); + if (this.remoteFieldsExists) { + const cb = function () { + that.renderFormNew(object); + }; + this.initFieldMasterData(cb); + } else { + this.initFieldMasterData(); + that.renderFormNew(object); + } + + this.currentReport = object; + } + + renderFormNew(object) { + const that = this; + const signatureIds = []; + if (object == null || object === undefined) { + this.currentId = null; + } + + this.preRenderForm(object); + + let formHtml = this.templates.formTemplate; + let html = ''; + const fields = this.getFormFields(); + + for (let i = 0; i < fields.length; i++) { + const metaField = this.getMetaFieldForRendering(fields[i][0]); + if (metaField === '' || metaField === undefined) { + html += this.renderFormField(fields[i]); + } else { + const metaVal = object[metaField]; + if (metaVal !== '' && metaVal != null && metaVal !== undefined && metaVal.trim() !== '') { + html += this.renderFormField(JSON.parse(metaVal)); + } else { + html += this.renderFormField(fields[i]); + } + } + } + formHtml = formHtml.replace(/_id_/g, `${this.getTableName()}_submit`); + formHtml = formHtml.replace(/_fields_/g, html); + + + let $tempDomObj; + const randomFormId = this.generateRandom(14); + if (!this.showFormOnPopup) { + $tempDomObj = $(`#${this.getTableName()}Form`); + } else { + $tempDomObj = $('
    '); + $tempDomObj.attr('id', randomFormId); + } + + $tempDomObj.html(formHtml); + + + $tempDomObj.find('.datefield').datepicker({ viewMode: 2 }); + $tempDomObj.find('.timefield').datetimepicker({ + language: 'en', + pickDate: false, + }); + $tempDomObj.find('.datetimefield').datetimepicker({ + language: 'en', + }); + + $tempDomObj.find('.colorpick').colorpicker(); + + // $tempDomObj.find('.select2Field').select2(); + $tempDomObj.find('.select2Field').each(function () { + $(this).select2().select2('val', $(this).find('option:eq(0)').val()); + }); + + $tempDomObj.find('.select2Multi').each(function () { + $(this).select2().on('change', function (e) { + const parentRow = $(this).parents('.row'); + const height = parentRow.find('.select2-choices').height(); + parentRow.height(parseInt(height, 10)); + }); + }); + + + $tempDomObj.find('.signatureField').each(function () { + // $(this).data('signaturePad',new SignaturePad($(this))); + signatureIds.push($(this).attr('id')); + }); + + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type === 'datagroup') { + $tempDomObj.find(`#${fields[i][0]}`).data('field', fields[i]); + } + } + + if (this.showSave === false) { + $tempDomObj.find('.saveBtn').remove(); + } else { + $tempDomObj.find('.saveBtn').off(); + $tempDomObj.find('.saveBtn').data('modJs', this); + $tempDomObj.find('.saveBtn').on('click', function () { + if ($(this).data('modJs').saveSuccessItemCallback != null && $(this).data('modJs').saveSuccessItemCallback !== undefined) { + $(this).data('modJs').save($(this).data('modJs').retriveItemsAfterSave(), $(this).data('modJs').saveSuccessItemCallback); + } else { + $(this).data('modJs').save(); + } + + return false; + }); + } + + if (this.showCancel === false) { + $tempDomObj.find('.cancelBtn').remove(); + } else { + $tempDomObj.find('.cancelBtn').off(); + $tempDomObj.find('.cancelBtn').data('modJs', this); + $tempDomObj.find('.cancelBtn').on('click', function () { + $(this).data('modJs').cancel(); + return false; + }); + } + + if (!this.showFormOnPopup) { + $(`#${this.getTableName()}Form`).show(); + $(`#${this.getTableName()}`).hide(); + + for (let i = 0; i < signatureIds.length; i++) { + $(`#${signatureIds[i]}`) + .data('signaturePad', + new SignaturePad(document.getElementById(signatureIds[i]))); + } + + if (object !== undefined && object != null) { + this.fillForm(object); + } + } else { + // var tHtml = $tempDomObj.wrap('
    ').parent().html(); + // this.showMessage("Edit",tHtml,null,null,true); + this.showMessage('Edit', '', null, null, true); + + $('#plainMessageModel .modal-body').html(''); + $('#plainMessageModel .modal-body').append($tempDomObj); + + + for (let i = 0; i < signatureIds.length; i++) { + $(`#${signatureIds[i]}`) + .data('signaturePad', + new SignaturePad(document.getElementById(signatureIds[i]))); + } + + if (object !== undefined && object != null) { + this.fillForm(object, `#${randomFormId}`); + } + } + + this.postRenderForm(object, $tempDomObj); + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + addSuccessCallBack(callBackData, serverData) { + const fileName = serverData[0]; + let link; + + if (fileName.indexOf('https:') === 0) { + link = `Download Report `; + } else { + link = `Download Report `; + } + link = link.replace(/_BASE_/g, this.baseUrl); + + if (this.currentReport.output === 'PDF' || this.currentReport.output === 'JSON') { + this.showMessage('Download Report', link); + } else { + if (serverData[1].length === 0) { + this.showMessage('Empty Report', 'There were no data for selected filters'); + return; + } + + + const tableHtml = `${link}

    `; + + // Delete existing temp report table + $('#tempReportTable').remove(); + + // this.showMessage("Report",tableHtml); + + $(`#${this.table}`).html(tableHtml); + $(`#${this.table}`).show(); + $(`#${this.table}Form`).hide(); + + // Prepare headers + const headers = []; + for (const index in serverData[1]) { + headers.push({ sTitle: serverData[1][index] }); + } + + const data = serverData[2]; + + + const dataTableParams = { + oLanguage: { + sLengthMenu: '_MENU_ records per page', + }, + aaData: data, + aoColumns: headers, + bSort: false, + iDisplayLength: 15, + iDisplayStart: 0, + }; + + $('#tempReportTable').dataTable(dataTableParams); + + $('.dataTables_paginate ul').addClass('pagination'); + $('.dataTables_length').hide(); + $('.dataTables_filter input').addClass('form-control'); + $('.dataTables_filter input').attr('placeholder', 'Search'); + $('.dataTables_filter label').contents().filter(function () { + return (this.nodeType === 3); + }).remove(); + $('.tableActionButton').tooltip(); + } + } + + + fillForm(object) { + const fields = this.getFormFields(); + for (let i = 0; i < fields.length; i++) { + if (fields[i][1].type === 'label') { + $(`#${this.getTableName()}Form #${fields[i][0]}`).html(object[fields[i][0]]); + } else { + $(`#${this.getTableName()}Form #${fields[i][0]}`).val(object[fields[i][0]]); + } + } + } +} + + +class ReportGenAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_name_/g, data[1]); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } +} + + +module.exports = { ReportAdapter, ReportGenAdapter }; diff --git a/web/admin/src/salary/index.js b/web/admin/src/salary/index.js new file mode 100644 index 00000000..08a5f45e --- /dev/null +++ b/web/admin/src/salary/index.js @@ -0,0 +1,9 @@ +import { + SalaryComponentTypeAdapter, + SalaryComponentAdapter, + EmployeeSalaryAdapter, +} from './lib'; + +window.SalaryComponentTypeAdapter = SalaryComponentTypeAdapter; +window.SalaryComponentAdapter = SalaryComponentAdapter; +window.EmployeeSalaryAdapter = EmployeeSalaryAdapter; diff --git a/web/admin/src/salary/lib.js b/web/admin/src/salary/lib.js new file mode 100644 index 00000000..e5ef5bb3 --- /dev/null +++ b/web/admin/src/salary/lib.js @@ -0,0 +1,120 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * SalaryComponentTypeAdapter + */ + +class SalaryComponentTypeAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'code', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Code' }, + { sTitle: 'Name' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['code', { label: 'Code', type: 'text', validation: '' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + + +/** + * SalaryComponentAdapter + */ + +class SalaryComponentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'componentType', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Salary Component Type' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['componentType', { label: 'Salary Component Type', type: 'select2', 'remote-source': ['SalaryComponentType', 'id', 'name'] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } +} + + +/* + * EmployeeSalaryAdapter + */ + +class EmployeeSalaryAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'component', + 'amount', + 'details', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Salary Component' }, + { sTitle: 'Amount' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['component', { label: 'Salary Component', type: 'select2', 'remote-source': ['SalaryComponent', 'id', 'name'] }], + ['amount', { label: 'Amount', type: 'text', validation: 'float' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ]; + } + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } +} + +module.exports = { + SalaryComponentTypeAdapter, + SalaryComponentAdapter, + EmployeeSalaryAdapter, +}; diff --git a/web/admin/src/settings/index.js b/web/admin/src/settings/index.js new file mode 100644 index 00000000..831bcc73 --- /dev/null +++ b/web/admin/src/settings/index.js @@ -0,0 +1,3 @@ +import { SettingAdapter } from './lib'; + +window.SettingAdapter = SettingAdapter; diff --git a/web/admin/src/settings/lib.js b/web/admin/src/settings/lib.js new file mode 100644 index 00000000..31d19ea0 --- /dev/null +++ b/web/admin/src/settings/lib.js @@ -0,0 +1,109 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; + +/** + * SettingAdapter + */ + +class SettingAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'value', + 'description', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Value' }, + { sTitle: 'Details' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['value', { label: 'Value', type: 'text', validation: 'none' }], + ]; + } + + getActionButtonsHtml(id, data) { + let html = '
    '; + html = html.replace(/_id_/g, id); + html = html.replace(/_BASE_/g, this.baseUrl); + return html; + } + + + getMetaFieldForRendering(fieldName) { + if (fieldName === 'value') { + return 'meta'; + } + return ''; + } + + edit(id) { + this.loadRemoteDataForSettings(); + super.edit(id); + } + + + fillForm(object) { + const metaField = this.getMetaFieldForRendering('value'); + const metaVal = object[metaField]; + let formFields = null; + + if (metaVal !== '' && metaVal !== undefined) { + formFields = [ + ['id', { label: 'ID', type: 'hidden' }], + JSON.parse(metaVal), + ]; + } + + super.fillForm(object, null, formFields); + $('#helptext').html(object.description); + } + + + loadRemoteDataForSettings() { + const fields = []; + let field = null; + fields.push(['country', { label: 'Country', type: 'select2multi', 'remote-source': ['Country', 'id', 'name'] }]); + fields.push(['countryCompany', { label: 'Country', type: 'select2', 'remote-source': ['Country', 'code', 'name'] }]); + fields.push(['currency', { label: 'Currency', type: 'select2multi', 'remote-source': ['CurrencyType', 'id', 'code+name'] }]); + fields.push(['nationality', { label: 'Nationality', type: 'select2multi', 'remote-source': ['Nationality', 'id', 'name'] }]); + fields.push(['supportedLanguage', { + label: 'Value', type: 'select2', 'allow-null': false, 'remote-source': ['SupportedLanguage', 'name', 'description'], + }]); + + for (const index in fields) { + field = fields[index]; + if (field[1]['remote-source'] !== undefined && field[1]['remote-source'] !== null) { + const key = `${field[1]['remote-source'][0]}_${field[1]['remote-source'][1]}_${field[1]['remote-source'][2]}`; + this.fieldMasterDataKeys[key] = false; + this.sourceMapping[field[0]] = field[1]['remote-source']; + + const callBackData = {}; + callBackData.callBack = 'initFieldMasterDataResponse'; + callBackData.callBackData = [key]; + + this.getFieldValues(field[1]['remote-source'], callBackData); + } + } + } + + + getHelpLink() { + return 'http://blog.icehrm.com/docs/settings/'; + } +} + +module.exports = { SettingAdapter }; diff --git a/web/admin/src/travel/index.js b/web/admin/src/travel/index.js new file mode 100644 index 00000000..6a4d434b --- /dev/null +++ b/web/admin/src/travel/index.js @@ -0,0 +1,11 @@ +import { + ImmigrationDocumentAdapter, + EmployeeImmigrationAdapter, + EmployeeTravelRecordAdminAdapter, + CustomFieldAdapter, +} from './lib'; + +window.ImmigrationDocumentAdapter = ImmigrationDocumentAdapter; +window.EmployeeImmigrationAdapter = EmployeeImmigrationAdapter; +window.EmployeeTravelRecordAdminAdapter = EmployeeTravelRecordAdminAdapter; +window.CustomFieldAdapter = CustomFieldAdapter; diff --git a/web/admin/src/travel/lib.js b/web/admin/src/travel/lib.js new file mode 100644 index 00000000..ea62815d --- /dev/null +++ b/web/admin/src/travel/lib.js @@ -0,0 +1,195 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import AdapterBase from '../../../api/AdapterBase'; +import CustomFieldAdapter from '../../../api/CustomFieldAdapter'; +import ApproveAdminAdapter from '../../../api/ApproveAdminAdapter'; + +/** + * ImmigrationDocumentAdapter + */ + +class ImmigrationDocumentAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + 'details', + 'required', + 'alert_on_missing', + 'alert_before_expiry', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + { sTitle: 'Details' }, + { sTitle: 'Compulsory' }, + { sTitle: 'Alert If Not Found' }, + { sTitle: 'Alert Before Expiry' }, + ]; + } + + getFormFields() { + const fields = [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['required', { label: 'Compulsory', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], + ['alert_on_missing', { label: 'Alert If Not Found', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], + ['alert_before_expiry', { label: 'Alert Before Expiry', type: 'select', source: [['No', 'No'], ['Yes', 'Yes']] }], + ['alert_before_day_number', { label: 'Days for Expiry Alert', type: 'text', validation: '' }], + ]; + + for (let i = 0; i < this.customFields.length; i++) { + fields.push(this.customFields[i]); + } + + return fields; + } +} + + +/** + * EmployeeImmigrationAdapter + */ + + +class EmployeeImmigrationAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'employee', + 'document', + 'documentname', + 'valid_until', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Document' }, + { sTitle: 'Document Id' }, + { sTitle: 'Valid Until' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + ['document', { label: 'Document', type: 'select2', 'remote-source': ['ImmigrationDocument', 'id', 'name'] }], + ['documentname', { label: 'Document Id', type: 'text', validation: '' }], + ['valid_until', { label: 'Valid Until', type: 'date', validation: 'none' }], + ['status', { label: 'Status', type: 'select', source: [['Active', 'Active'], ['Inactive', 'Inactive'], ['Draft', 'Draft']] }], + ['details', { label: 'Details', type: 'textarea', validation: 'none' }], + ['attachment1', { label: 'Attachment 1', type: 'fileupload', validation: 'none' }], + ['attachment2', { label: 'Attachment 2', type: 'fileupload', validation: 'none' }], + ['attachment3', { label: 'Attachment 3', type: 'fileupload', validation: 'none' }], + ]; + } + + + getFilters() { + return [ + ['employee', { label: 'Employee', type: 'select2', 'remote-source': ['Employee', 'id', 'first_name+last_name'] }], + + ]; + } +} + + +/** + * EmployeeTravelRecordAdminAdapter + */ + + +class EmployeeTravelRecordAdminAdapter extends ApproveAdminAdapter { + constructor(endPoint, tab, filter, orderBy) { + super(endPoint, tab, filter, orderBy); + this.itemName = 'TravelRequest'; + this.itemNameLower = 'travelrequest'; + this.modulePathName = 'travel'; + } + + getDataMapping() { + return [ + 'id', + 'employee', + 'type', + 'purpose', + 'travel_from', + 'travel_to', + 'travel_date', + 'status', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Employee' }, + { sTitle: 'Travel Type' }, + { sTitle: 'Purpose' }, + { sTitle: 'From' }, + { sTitle: 'To' }, + { sTitle: 'Travel Date' }, + { sTitle: 'Status' }, + ]; + } + + getFormFields() { + return this.addCustomFields([ + ['id', { label: 'ID', type: 'hidden' }], + ['employee', { + label: 'Employee', + type: 'select2', + sort: 'none', + 'allow-null': false, + 'remote-source': ['Employee', 'id', 'first_name+last_name', 'getActiveSubordinateEmployees'], + }], + ['type', { + label: 'Means of Transportation', + type: 'select', + source: [ + ['Plane', 'Plane'], + ['Rail', 'Rail'], + ['Taxi', 'Taxi'], + ['Own Vehicle', 'Own Vehicle'], + ['Rented Vehicle', 'Rented Vehicle'], + ['Other', 'Other'], + ], + }], + ['purpose', { label: 'Purpose of Travel', type: 'textarea', validation: '' }], + ['travel_from', { label: 'Travel From', type: 'text', validation: '' }], + ['travel_to', { label: 'Travel To', type: 'text', validation: '' }], + ['travel_date', { label: 'Travel Date', type: 'datetime', validation: '' }], + ['return_date', { label: 'Return Date', type: 'datetime', validation: '' }], + ['details', { label: 'Notes', type: 'textarea', validation: 'none' }], + ['currency', { + label: 'Currency', type: 'select2', 'allow-null': false, 'remote-source': ['CurrencyType', 'id', 'code'], + }], + ['funding', { + label: 'Total Funding Proposed', type: 'text', validation: 'float', default: '0.00', mask: '9{0,10}.99', + }], + ['attachment1', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ['attachment2', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ['attachment3', { label: 'Attachment', type: 'fileupload', validation: 'none' }], + ]); + } +} + +module.exports = { + ImmigrationDocumentAdapter, + EmployeeImmigrationAdapter, + EmployeeTravelRecordAdminAdapter, + CustomFieldAdapter, +}; diff --git a/web/admin/src/users/index.js b/web/admin/src/users/index.js new file mode 100644 index 00000000..8079bd20 --- /dev/null +++ b/web/admin/src/users/index.js @@ -0,0 +1,7 @@ +import { + UserAdapter, + UserRoleAdapter, +} from './lib'; + +window.UserAdapter = UserAdapter; +window.UserRoleAdapter = UserRoleAdapter; diff --git a/web/admin/src/users/lib.js b/web/admin/src/users/lib.js new file mode 100644 index 00000000..e113f181 --- /dev/null +++ b/web/admin/src/users/lib.js @@ -0,0 +1,201 @@ +/* +Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) +Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +import FormValidation from '../../../api/FormValidation'; +import AdapterBase from '../../../api/AdapterBase'; + + +class UserAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'username', + 'email', + 'employee', + 'user_level', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID' }, + { sTitle: 'User Name' }, + { sTitle: 'Authentication Email' }, + { sTitle: 'Employee' }, + { sTitle: 'User Level' }, + ]; + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden', validation: '' }], + ['username', { label: 'User Name', type: 'text', validation: 'username' }], + ['email', { label: 'Email', type: 'text', validation: 'email' }], + ['employee', { + label: 'Employee', type: 'select2', 'allow-null': true, 'remote-source': ['Employee', 'id', 'first_name+last_name'], + }], + ['user_level', { label: 'User Level', type: 'select', source: [['Admin', 'Admin'], ['Manager', 'Manager'], ['Employee', 'Employee'], ['Other', 'Other']] }], + ['user_roles', { label: 'User Roles', type: 'select2multi', 'remote-source': ['UserRole', 'id', 'name'] }], + ['lang', { + label: 'Language', type: 'select2', 'allow-null': true, 'remote-source': ['SupportedLanguage', 'id', 'description'], + }], + ['default_module', { + label: 'Default Module', type: 'select2', 'null-label': 'No Default Module', 'allow-null': true, 'remote-source': ['Module', 'id', 'menu+label'], + }], + ]; + } + + postRenderForm(object, $tempDomObj) { + if (object == null || object === undefined) { + $tempDomObj.find('#changePasswordBtn').remove(); + } + } + + changePassword() { + $('#adminUsersModel').modal('show'); + $('#adminUsersChangePwd #newpwd').val(''); + $('#adminUsersChangePwd #conpwd').val(''); + } + + saveUserSuccessCallBack(callBackData, serverData) { + const user = callBackData[0]; + if (callBackData[1]) { + this.showMessage('Create User', `An email has been sent to ${user.email} with a temporary password to login to IceHrm.`); + } else { + this.showMessage('Create User', 'User created successfully. But there was a problem sending welcome email.'); + } + this.get([]); + } + + saveUserFailCallBack(callBackData, serverData) { + this.showMessage('Error', callBackData); + } + + doCustomValidation(params) { + let msg = null; + if ((params.user_level !== 'Admin' && params.user_level !== 'Other') && params.employee === 'NULL') { + msg = 'For this user type, you have to assign an employee when adding or editing the user.
    '; + msg += " You may create a new employee through 'Admin'->'Employees' menu"; + } + return msg; + } + + save() { + const validator = new FormValidation(`${this.getTableName()}_submit`, true, { ShowPopup: false, LabelErrorClass: 'error' }); + if (validator.checkValues()) { + const params = validator.getFormParameters(); + + const msg = this.doCustomValidation(params); + if (msg == null) { + const id = $(`#${this.getTableName()}_submit #id`).val(); + params.csrf = $(`#${this.getTableName()}Form`).data('csrf'); + if (id != null && id !== undefined && id !== '') { + params.id = id; + this.add(params, []); + } else { + const reqJson = JSON.stringify(params); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'saveUserSuccessCallBack'; + callBackData.callBackFail = 'saveUserFailCallBack'; + + this.customAction('saveUser', 'admin=users', reqJson, callBackData); + } + } else { + // $("#"+this.getTableName()+'Form .label').html(msg); + // $("#"+this.getTableName()+'Form .label').show(); + this.showMessage('Error Saving User', msg); + } + } + } + + + changePasswordConfirm() { + $('#adminUsersChangePwd_error').hide(); + + const passwordValidation = function (str) { + return str.length > 7; + }; + + const password = $('#adminUsersChangePwd #newpwd').val(); + + if (!passwordValidation(password)) { + $('#adminUsersChangePwd_error').html('Password should be longer than 7 characters'); + $('#adminUsersChangePwd_error').show(); + return; + } + + const conPassword = $('#adminUsersChangePwd #conpwd').val(); + + if (conPassword !== password) { + $('#adminUsersChangePwd_error').html("Passwords don't match"); + $('#adminUsersChangePwd_error').show(); + return; + } + + const req = { id: this.currentId, pwd: conPassword }; + const reqJson = JSON.stringify(req); + + const callBackData = []; + callBackData.callBackData = []; + callBackData.callBackSuccess = 'changePasswordSuccessCallBack'; + callBackData.callBackFail = 'changePasswordFailCallBack'; + + this.customAction('changePassword', 'admin=users', reqJson, callBackData); + } + + closeChangePassword() { + $('#adminUsersModel').modal('hide'); + } + + changePasswordSuccessCallBack(callBackData, serverData) { + this.closeChangePassword(); + this.showMessage('Password Change', 'Password changed successfully'); + } + + changePasswordFailCallBack(callBackData, serverData) { + this.closeChangePassword(); + this.showMessage('Error', callBackData); + } +} + + +/** + * UserRoleAdapter + */ + +class UserRoleAdapter extends AdapterBase { + getDataMapping() { + return [ + 'id', + 'name', + ]; + } + + getHeaders() { + return [ + { sTitle: 'ID', bVisible: false }, + { sTitle: 'Name' }, + ]; + } + + + postRenderForm(object, $tempDomObj) { + $tempDomObj.find('#changePasswordBtn').remove(); + } + + getFormFields() { + return [ + ['id', { label: 'ID', type: 'hidden' }], + ['name', { label: 'Name', type: 'text', validation: '' }], + ]; + } +} + +module.exports = { + UserAdapter, + UserRoleAdapter, +}; diff --git a/web/api-common/Aes.js b/web/api-common/Aes.js new file mode 100644 index 00000000..22d22872 --- /dev/null +++ b/web/api-common/Aes.js @@ -0,0 +1,497 @@ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/* AES implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* jshint node:true *//* global define */ + + +/** + * AES (Rijndael cipher) encryption routines, + * + * Reference implementation of FIPS-197 http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf. + * + * @namespace + */ +var Aes = {}; + + +/** + * AES Cipher function: encrypt 'input' state with Rijndael algorithm [§5.1]; + * applies Nr rounds (10/12/14) using key schedule w for 'add round key' stage. + * + * @param {number[]} input - 16-byte (128-bit) input state array. + * @param {number[][]} w - Key schedule as 2D byte-array (Nr+1 x Nb bytes). + * @returns {number[]} Encrypted output state array. + */ +Aes.cipher = function (input, w) { + const Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) + const Nr = w.length / Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys + + let state = [[], [], [], []]; // initialise 4xNb byte-array 'state' with input [§3.4] + for (var i = 0; i < 4 * Nb; i++) state[i % 4][Math.floor(i / 4)] = input[i]; + + state = Aes.addRoundKey(state, w, 0, Nb); + + for (let round = 1; round < Nr; round++) { + state = Aes.subBytes(state, Nb); + state = Aes.shiftRows(state, Nb); + state = Aes.mixColumns(state, Nb); + state = Aes.addRoundKey(state, w, round, Nb); + } + + state = Aes.subBytes(state, Nb); + state = Aes.shiftRows(state, Nb); + state = Aes.addRoundKey(state, w, Nr, Nb); + + const output = new Array(4 * Nb); // convert state to 1-d array before returning [§3.4] + for (var i = 0; i < 4 * Nb; i++) output[i] = state[i % 4][Math.floor(i / 4)]; + + return output; +}; + + +/** + * Perform key expansion to generate a key schedule from a cipher key [§5.2]. + * + * @param {number[]} key - Cipher key as 16/24/32-byte array. + * @returns {number[][]} Expanded key schedule as 2D byte-array (Nr+1 x Nb bytes). + */ +Aes.keyExpansion = function (key) { + const Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES) + const Nk = key.length / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys + const Nr = Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys + + const w = new Array(Nb * (Nr + 1)); + let temp = new Array(4); + + // initialise first Nk words of expanded key with cipher key + for (var i = 0; i < Nk; i++) { + const r = [key[4 * i], key[4 * i + 1], key[4 * i + 2], key[4 * i + 3]]; + w[i] = r; + } + + // expand the key into the remainder of the schedule + for (var i = Nk; i < (Nb * (Nr + 1)); i++) { + w[i] = new Array(4); + for (var t = 0; t < 4; t++) temp[t] = w[i - 1][t]; + // each Nk'th word has extra transformation + if (i % Nk == 0) { + temp = Aes.subWord(Aes.rotWord(temp)); + for (var t = 0; t < 4; t++) temp[t] ^= Aes.rCon[i / Nk][t]; + } + // 256-bit key has subWord applied every 4th word + else if (Nk > 6 && i % Nk == 4) { + temp = Aes.subWord(temp); + } + // xor w[i] with w[i-1] and w[i-Nk] + for (var t = 0; t < 4; t++) w[i][t] = w[i - Nk][t] ^ temp[t]; + } + + return w; +}; + + +/** + * Apply SBox to state S [§5.1.1] + * @private + */ +Aes.subBytes = function (s, Nb) { + for (let r = 0; r < 4; r++) { + for (let c = 0; c < Nb; c++) s[r][c] = Aes.sBox[s[r][c]]; + } + return s; +}; + + +/** + * Shift row r of state S left by r bytes [§5.1.2] + * @private + */ +Aes.shiftRows = function (s, Nb) { + const t = new Array(4); + for (let r = 1; r < 4; r++) { + for (var c = 0; c < 4; c++) t[c] = s[r][(c + r) % Nb]; // shift into temp copy + for (var c = 0; c < 4; c++) s[r][c] = t[c]; // and copy back + } // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES): + return s; // see asmaes.sourceforge.net/rijndael/rijndaelImplementation.pdf +}; + + +/** + * Combine bytes of each col of state S [§5.1.3] + * @private + */ +Aes.mixColumns = function (s, Nb) { + for (let c = 0; c < 4; c++) { + const a = new Array(4); // 'a' is a copy of the current column from 's' + const b = new Array(4); // 'b' is a•{02} in GF(2^8) + for (let i = 0; i < 4; i++) { + a[i] = s[i][c]; + b[i] = s[i][c] & 0x80 ? s[i][c] << 1 ^ 0x011b : s[i][c] << 1; + } + // a[n] ^ b[n] is a•{03} in GF(2^8) + s[0][c] = b[0] ^ a[1] ^ b[1] ^ a[2] ^ a[3]; // {02}•a0 + {03}•a1 + a2 + a3 + s[1][c] = a[0] ^ b[1] ^ a[2] ^ b[2] ^ a[3]; // a0 • {02}•a1 + {03}•a2 + a3 + s[2][c] = a[0] ^ a[1] ^ b[2] ^ a[3] ^ b[3]; // a0 + a1 + {02}•a2 + {03}•a3 + s[3][c] = a[0] ^ b[0] ^ a[1] ^ a[2] ^ b[3]; // {03}•a0 + a1 + a2 + {02}•a3 + } + return s; +}; + + +/** + * Xor Round Key into state S [§5.1.4] + * @private + */ +Aes.addRoundKey = function (state, w, rnd, Nb) { + for (let r = 0; r < 4; r++) { + for (let c = 0; c < Nb; c++) state[r][c] ^= w[rnd * 4 + c][r]; + } + return state; +}; + + +/** + * Apply SBox to 4-byte word w + * @private + */ +Aes.subWord = function (w) { + for (let i = 0; i < 4; i++) w[i] = Aes.sBox[w[i]]; + return w; +}; + + +/** + * Rotate 4-byte word w left by one byte + * @private + */ +Aes.rotWord = function (w) { + const tmp = w[0]; + for (let i = 0; i < 3; i++) w[i] = w[i + 1]; + w[3] = tmp; + return w; +}; + + +// sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [§5.1.1] +Aes.sBox = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + + +// rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [§5.2] +Aes.rCon = [[0x00, 0x00, 0x00, 0x00], + [0x01, 0x00, 0x00, 0x00], + [0x02, 0x00, 0x00, 0x00], + [0x04, 0x00, 0x00, 0x00], + [0x08, 0x00, 0x00, 0x00], + [0x10, 0x00, 0x00, 0x00], + [0x20, 0x00, 0x00, 0x00], + [0x40, 0x00, 0x00, 0x00], + [0x80, 0x00, 0x00, 0x00], + [0x1b, 0x00, 0x00, 0x00], + [0x36, 0x00, 0x00, 0x00]]; + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +if (typeof module !== 'undefined' && module.exports) module.exports = Aes; // CommonJs export +if (typeof define === 'function' && define.amd) define([], () => Aes); // AMD + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/* AES Counter-mode implementation in JavaScript (c) Chris Veness 2005-2014 / MIT Licence */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* jshint node:true *//* global define, escape, unescape, btoa, atob */ +'use strict'; +if (typeof module !== 'undefined' && module.exports) var Aes = require('./aes'); // CommonJS (Node.js) + + +/** + * Aes.Ctr: Counter-mode (CTR) wrapper for AES. + * + * This encrypts a Unicode string to produces a base64 ciphertext using 128/192/256-bit AES, + * and the converse to decrypt an encrypted ciphertext. + * + * See http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf + * + * @augments Aes + */ +Aes.Ctr = {}; + + +/** + * Encrypt a text using AES encryption in Counter mode of operation. + * + * Unicode multi-byte character safe + * + * @param {string} plaintext - Source text to be encrypted. + * @param {string} password - The password to use to generate a key. + * @param {number} nBits - Number of bits to be used in the key; 128 / 192 / 256. + * @returns {string} Encrypted text. + * + * @example + * var encr = Aes.Ctr.encrypt('big secret', 'pāşšŵōřđ', 256); // encr: 'lwGl66VVwVObKIr6of8HVqJr' + */ +Aes.Ctr.encrypt = function (plaintext, password, nBits) { + const blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES + if (!(nBits == 128 || nBits == 192 || nBits == 256)) return ''; // standard allows 128/192/256 bit keys + plaintext = String(plaintext).utf8Encode(); + password = String(password).utf8Encode(); + + // use AES itself to encrypt password to get cipher key (using plain password as source for key + // expansion) - gives us well encrypted key (though hashed key might be preferred for prod'n use) + const nBytes = nBits / 8; // no bytes in key (16/24/32) + const pwBytes = new Array(nBytes); + for (var i = 0; i < nBytes; i++) { // use 1st 16/24/32 chars of password for key + pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i); + } + let key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes)); // gives us 16-byte key + key = key.concat(key.slice(0, nBytes - 16)); // expand key to 16/24/32 bytes long + + // initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A §B.2): [0-1] = millisec, + // [2-3] = random, [4-7] = seconds, together giving full sub-millisec uniqueness up to Feb 2106 + const counterBlock = new Array(blockSize); + + const nonce = (new Date()).getTime(); // timestamp: milliseconds since 1-Jan-1970 + const nonceMs = nonce % 1000; + const nonceSec = Math.floor(nonce / 1000); + const nonceRnd = Math.floor(Math.random() * 0xffff); + // for debugging: nonce = nonceMs = nonceSec = nonceRnd = 0; + + for (var i = 0; i < 2; i++) counterBlock[i] = (nonceMs >>> i * 8) & 0xff; + for (var i = 0; i < 2; i++) counterBlock[i + 2] = (nonceRnd >>> i * 8) & 0xff; + for (var i = 0; i < 4; i++) counterBlock[i + 4] = (nonceSec >>> i * 8) & 0xff; + + // and convert it to a string to go on the front of the ciphertext + let ctrTxt = ''; + for (var i = 0; i < 8; i++) ctrTxt += String.fromCharCode(counterBlock[i]); + + // generate key schedule - an expansion of the key into distinct Key Rounds for each round + const keySchedule = Aes.keyExpansion(key); + + const blockCount = Math.ceil(plaintext.length / blockSize); + const ciphertxt = new Array(blockCount); // ciphertext as array of strings + + for (let b = 0; b < blockCount; b++) { + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) + // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB) + for (var c = 0; c < 4; c++) counterBlock[15 - c] = (b >>> c * 8) & 0xff; + for (var c = 0; c < 4; c++) counterBlock[15 - c - 4] = (b / 0x100000000 >>> c * 8); + + const cipherCntr = Aes.cipher(counterBlock, keySchedule); // -- encrypt counter block -- + + // block size is reduced on final block + const blockLength = b < blockCount - 1 ? blockSize : (plaintext.length - 1) % blockSize + 1; + const cipherChar = new Array(blockLength); + + for (var i = 0; i < blockLength; i++) { // -- xor plaintext with ciphered counter char-by-char -- + cipherChar[i] = cipherCntr[i] ^ plaintext.charCodeAt(b * blockSize + i); + cipherChar[i] = String.fromCharCode(cipherChar[i]); + } + ciphertxt[b] = cipherChar.join(''); + } + + // use Array.join() for better performance than repeated string appends + let ciphertext = ctrTxt + ciphertxt.join(''); + ciphertext = ciphertext.base64Encode(); + + return ciphertext; +}; + + +/** + * Decrypt a text encrypted by AES in counter mode of operation + * + * @param {string} ciphertext - Source text to be encrypted. + * @param {string} password - Password to use to generate a key. + * @param {number} nBits - Number of bits to be used in the key; 128 / 192 / 256. + * @returns {string} Decrypted text + * + * @example + * var decr = Aes.Ctr.encrypt('lwGl66VVwVObKIr6of8HVqJr', 'pāşšŵōřđ', 256); // decr: 'big secret' + */ +Aes.Ctr.decrypt = function (ciphertext, password, nBits) { + const blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES + if (!(nBits == 128 || nBits == 192 || nBits == 256)) return ''; // standard allows 128/192/256 bit keys + ciphertext = String(ciphertext).base64Decode(); + password = String(password).utf8Encode(); + + // use AES to encrypt password (mirroring encrypt routine) + const nBytes = nBits / 8; // no bytes in key + const pwBytes = new Array(nBytes); + for (var i = 0; i < nBytes; i++) { + pwBytes[i] = isNaN(password.charCodeAt(i)) ? 0 : password.charCodeAt(i); + } + let key = Aes.cipher(pwBytes, Aes.keyExpansion(pwBytes)); + key = key.concat(key.slice(0, nBytes - 16)); // expand key to 16/24/32 bytes long + + // recover nonce from 1st 8 bytes of ciphertext + const counterBlock = new Array(8); + const ctrTxt = ciphertext.slice(0, 8); + for (var i = 0; i < 8; i++) counterBlock[i] = ctrTxt.charCodeAt(i); + + // generate key schedule + const keySchedule = Aes.keyExpansion(key); + + // separate ciphertext into blocks (skipping past initial 8 bytes) + const nBlocks = Math.ceil((ciphertext.length - 8) / blockSize); + const ct = new Array(nBlocks); + for (var b = 0; b < nBlocks; b++) ct[b] = ciphertext.slice(8 + b * blockSize, 8 + b * blockSize + blockSize); + ciphertext = ct; // ciphertext is now array of block-length strings + + // plaintext will get generated block-by-block into array of block-length strings + const plaintxt = new Array(ciphertext.length); + + for (var b = 0; b < nBlocks; b++) { + // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes) + for (var c = 0; c < 4; c++) counterBlock[15 - c] = ((b) >>> c * 8) & 0xff; + for (var c = 0; c < 4; c++) counterBlock[15 - c - 4] = (((b + 1) / 0x100000000 - 1) >>> c * 8) & 0xff; + + const cipherCntr = Aes.cipher(counterBlock, keySchedule); // encrypt counter block + + const plaintxtByte = new Array(ciphertext[b].length); + for (var i = 0; i < ciphertext[b].length; i++) { + // -- xor plaintxt with ciphered counter byte-by-byte -- + plaintxtByte[i] = cipherCntr[i] ^ ciphertext[b].charCodeAt(i); + plaintxtByte[i] = String.fromCharCode(plaintxtByte[i]); + } + plaintxt[b] = plaintxtByte.join(''); + } + + // join array of blocks into single plaintext string + let plaintext = plaintxt.join(''); + plaintext = plaintext.utf8Decode(); // decode from UTF8 back to Unicode multi-byte chars + + return plaintext; +}; + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + +/** Extend String object with method to encode multi-byte string to utf8 + * - monsur.hossa.in/2012/07/20/utf-8-in-javascript.html */ +if (typeof String.prototype.utf8Encode === 'undefined') { + String.prototype.utf8Encode = function () { + return unescape(encodeURIComponent(this)); + }; +} + +/** Extend String object with method to decode utf8 string to multi-byte */ +if (typeof String.prototype.utf8Decode === 'undefined') { + String.prototype.utf8Decode = function () { + try { + return decodeURIComponent(escape(this)); + } catch (e) { + return this; // invalid UTF-8? return as-is + } + }; +} + + +/** Extend String object with method to encode base64 + * - developer.mozilla.org/en-US/docs/Web/API/window.btoa, nodejs.org/api/buffer.html + * note: if btoa()/atob() are not available (eg IE9-), try github.com/davidchambers/Base64.js */ +if (typeof String.prototype.base64Encode === 'undefined') { + String.prototype.base64Encode = function () { + if (typeof btoa !== 'undefined') return btoa(this); // browser + if (typeof Buffer !== 'undefined') return new Buffer(this, 'utf8').toString('base64'); // Node.js + throw new Error('No Base64 Encode'); + }; +} + +/** Extend String object with method to decode base64 */ +if (typeof String.prototype.base64Decode === 'undefined') { + String.prototype.base64Decode = function () { + if (typeof atob !== 'undefined') return atob(this); // browser + if (typeof Buffer !== 'undefined') return new Buffer(this, 'base64').toString('utf8'); // Node.js + throw new Error('No Base64 Decode'); + }; +} + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +if (typeof module !== 'undefined' && module.exports) module.exports = Aes.Ctr; // CommonJs export +if (typeof define === 'function' && define.amd) define(['Aes'], () => Aes.Ctr); // AMD + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +/* Encrypt/decrypt files */ +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +function encryptFile(file) { + // use FileReader.readAsArrayBuffer to handle binary files + const reader = new FileReader(); + reader.readAsArrayBuffer(file); + reader.onload = function (evt) { + $('body').css({ cursor: 'wait' }); + + // Aes.Ctr.encrypt expects a string, but converting binary file directly to string could + // give invalid Unicode sequences, so convert bytestream ArrayBuffer to single-byte chars + const contentBytes = new Uint8Array(reader.result); // ≡ evt.target.result + let contentStr = ''; + for (let i = 0; i < contentBytes.length; i++) { + contentStr += String.fromCharCode(contentBytes[i]); + } + + const password = $('#password-file').val(); + + const t1 = new Date(); + const ciphertext = Aes.Ctr.encrypt(contentStr, password, 256); + const t2 = new Date(); + + // use Blob to save encrypted file + const blob = new Blob([ciphertext], { type: 'text/plain' }); + const filename = `${file.name}.encrypted`; + saveAs(blob, filename); + + $('#encrypt-file-time').html(`${(t2 - t1) / 1000}s`); // display time taken + $('body').css({ cursor: 'default' }); + }; +} + +function decryptFile(file) { + // use FileReader.ReadAsText to read (base64-encoded) ciphertext file + const reader = new FileReader(); + reader.readAsText(file); + reader.onload = function (evt) { + $('body').css({ cursor: 'wait' }); + + const content = reader.result; // ≡ evt.target.result + const password = $('#password-file').val(); + + const t1 = new Date(); + const plaintext = Aes.Ctr.decrypt(content, password, 256); + const t2 = new Date(); + + // convert single-byte character stream to ArrayBuffer bytestream + const contentBytes = new Uint8Array(plaintext.length); + for (let i = 0; i < plaintext.length; i++) { + contentBytes[i] = plaintext.charCodeAt(i); + } + + // use Blob to save decrypted file + const blob = new Blob([contentBytes], { type: 'application/octet-stream' }); + const filename = `${file.name.replace(/\.encrypted$/, '')}.decrypted`; + saveAs(blob, filename); + + $('#decrypt-file-time').html(`${(t2 - t1) / 1000}s`); // display time taken + $('body').css({ cursor: 'default' }); + }; +} + +export default Aes; diff --git a/web/api-common/Notifications.js b/web/api-common/Notifications.js new file mode 100644 index 00000000..1bdf5994 --- /dev/null +++ b/web/api-common/Notifications.js @@ -0,0 +1,124 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ +class NotificationManager { + constructor() { + this.baseUrl = ''; + this.templates = {}; + } + + setBaseUrl(url) { + this.baseUrl = url; + } + + setTemplates(data) { + this.templates = data; + } + + setTimeUtils(timeUtils) { + this.timeUtils = timeUtils; + } + + getNotifications(name, data) { + const that = this; + $.getJSON(this.baseUrl, { a: 'getNotifications' }, (_data) => { + if (_data.status === 'SUCCESS') { + that.renderNotifications(_data.data[1], _data.data[0]); + } + }); + } + + clearPendingNotifications(name, data) { + const that = this; + $.getJSON(this.baseUrl, { a: 'clearNotifications' }, (_data) => { + + }); + } + + renderNotifications(notifications, unreadCount) { + if (notifications.length === 0) { + return; + } + + let t = this.templates.notifications; + if (unreadCount > 0) { + t = t.replace('#_count_#', unreadCount); + if (unreadCount > 1) { + t = t.replace('#_header_#', `You have ${unreadCount} new notifications`); + } else { + t = t.replace('#_header_#', `You have ${unreadCount} new notification`); + } + } else { + t = t.replace('#_count_#', ''); + t = t.replace('#_header_#', 'You have no new notifications'); + } + + let notificationStr = ''; + + for (const index in notifications) { + notificationStr += this.renderNotification(notifications[index]); + } + + t = t.replace('#_notifications_#', notificationStr); + + const $obj = $(t); + + if (unreadCount === 0) { + $obj.find('.label-danger').remove(); + } + + $obj.attr('id', 'notifications'); + const k = $('#notifications'); + k.replaceWith($obj); + + $('.navbar .menu').slimscroll({ + height: '320px', + alwaysVisible: false, + size: '3px', + }).css('width', '100%'); + + this.timeUtils.convertToRelativeTime($('.notificationTime')); + } + + + renderNotification(notification) { + let t = this.templates.notification; + t = t.replace('#_image_#', notification.image); + + try { + const json = JSON.parse(notification.action); + t = t.replace('#_url_#', this.baseUrl.replace('service.php', '?') + json.url); + } catch (e) { + t = t.replace('#_url_#', ''); + } + + t = t.replace('#_time_#', notification.time); + t = t.replace('#_fromName_#', notification.type); + t = t.replace('#_message_#', this.getLineBreakString(notification.message, 27)); + return t; + } + + + getLineBreakString(str, len) { + let t = ''; + try { + const arr = str.split(' '); + let count = 0; + for (let i = 0; i < arr.length; i++) { + count += arr[i].length + 1; + if (count > len) { + t += `${arr[i]}
    `; + count = 0; + } else { + t += `${arr[i]} `; + } + } + } catch (e) { + // Do nothing + } + return t; + } +} + +export default NotificationManager; diff --git a/web/api-common/RequestCache.js b/web/api-common/RequestCache.js new file mode 100644 index 00000000..961e5030 --- /dev/null +++ b/web/api-common/RequestCache.js @@ -0,0 +1,69 @@ +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +/** + * RequestCache + */ + +class RequestCache { + getKey(url, params) { + let key = `${url}|`; + for (const index in params) { + key += `${index}=${params[index]}|`; + } + return key; + } + + invalidateTable(table) { + let key; + for (let i = 0; i < localStorage.length; i++) { + key = localStorage.key(i); + if (key.indexOf(`t=${table}`) > 0) { + localStorage.removeItem(key); + } + } + } + + + getData(key) { + let data; + + if (typeof (Storage) === 'undefined') { + return null; + } + + const strData = localStorage.getItem(key); + if (strData !== undefined && strData != null && strData !== '') { + data = JSON.parse(strData); + if (data === undefined || data == null) { + return null; + } + + if (data.status !== undefined && data.status != null && data.status !== 'SUCCESS') { + return null; + } + + return data; + } + + return null; + } + + setData(key, data) { + if (typeof (Storage) === 'undefined') { + return null; + } + + if (data.status !== undefined && data.status != null && data.status !== 'SUCCESS') { + return null; + } + + const strData = JSON.stringify(data); + localStorage.setItem(key, strData); + return strData; + } +} + +export default RequestCache; diff --git a/web/api-common/TimeUtils.js b/web/api-common/TimeUtils.js new file mode 100644 index 00000000..7f432d74 --- /dev/null +++ b/web/api-common/TimeUtils.js @@ -0,0 +1,143 @@ +/* eslint-disable camelcase,brace-style */ + +/* + Copyright (c) 2018 [Glacies UG, Berlin, Germany] (http://glacies.de) + Developer: Thilina Hasantha (http://lk.linkedin.com/in/thilinah | https://github.com/thilinah) + */ + +class TimeUtils { + setServerGMToffset(serverGMToffset) { + this.serverGMToffset = serverGMToffset; + } + + getMySQLFormatDate(date) { + const format = function (val) { + if (val < 10) { return `0${val}`; } + return val; + }; + + return `${date.getUTCFullYear()}-${format(date.getUTCMonth() + 1)}-${format(date.getUTCDate())}`; + } + + convertToRelativeTime(selector) { + const that = this; + + const getAmPmTime = function (curHour, curMin) { + let amPm = 'am'; + let amPmHour = curHour; + if (amPmHour >= 12) { + amPm = 'pm'; + if (amPmHour > 12) { + amPmHour -= 12; + } + } + let prefixCurMin = ''; + if (curMin < 10) { + prefixCurMin = '0'; + } + + let prefixCurHour = ''; + if (curHour === 0) { + prefixCurHour = '0'; + } + return ` at ${prefixCurHour}${amPmHour}:${prefixCurMin}${curMin}${amPm}`; + }; + + const getBrowserTimeZone = function () { + const current_date = new Date(); + const gmt_offset = current_date.getTimezoneOffset() / 60; + return -gmt_offset; + }; + + const curDate = new Date(); + const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; + const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; + + + const timezoneDiff = this.serverGMToffset - getBrowserTimeZone(); + const timezoneTimeDiff = timezoneDiff * 60 * 60 * 1000; + + + selector.each(function () { + try { + const thisValue = $(this).html(); + // Split value into date and time + const thisValueArray = thisValue.split(' '); + const thisValueDate = thisValueArray[0]; + const thisValueTime = thisValueArray[1]; + + // Split date into components + const thisValueDateArray = thisValueDate.split('-'); + const curYear = thisValueDateArray[0]; + const curMonth = thisValueDateArray[1] - 1; + const curDay = thisValueDateArray[2]; + + // Split time into components + const thisValueTimeArray = thisValueTime.split(':'); + const curHour = thisValueTimeArray[0]; + const curMin = thisValueTimeArray[1]; + const curSec = thisValueTimeArray[2]; + + // Create this date + const thisDate = new Date(curYear, curMonth, curDay, curHour, curMin, curSec); + const thisTime = thisDate.getTime(); + const tzDate = new Date(thisTime - timezoneTimeDiff); + // var tzDay = tzDate.getDay();//getDay will return the day of the week not the month + // var tzDay = tzDate.getUTCDate(); //getUTCDate will return the day of the month + const tzDay = tzDate.toString('d'); // + const tzYear = tzDate.getFullYear(); + const tzHour = tzDate.getHours(); + const tzMin = tzDate.getMinutes(); + + // Create the full date + // var fullDate = days[tzDate.getDay()] + ", " + months[tzDate.getMonth()] + " " + tzDay + ", " + tzYear + getAmPmTime(tzHour, tzMin); + const fullDate = `${days[tzDate.getDay()]}, ${months[tzDate.getMonth()]} ${tzDay}, ${tzYear}${getAmPmTime(tzHour, tzMin)}`; + + // Get the time different + const timeDiff = (curDate.getTime() - tzDate.getTime()) / 1000; + const minDiff = Math.abs(timeDiff / 60); + const hourDiff = Math.abs(timeDiff / (60 * 60)); + const dayDiff = Math.abs(timeDiff / (60 * 60 * 24)); + const yearDiff = Math.abs(timeDiff / (60 * 60 * 24 * 365)); + + // If more than a day old, display the month, day and time (and year, if applicable) + let fbDate = ''; + if (dayDiff > 1) { + // fbDate = curDay + " " + months[tzDate.getMonth()].substring(0,3); + fbDate = `${tzDay} ${months[tzDate.getMonth()].substring(0, 3)}`; + // Add the year, if applicable + if (yearDiff > 1) { + fbDate = `${fbDate} ${curYear}`; + } + + // Add the time + fbDate += getAmPmTime(tzHour, tzMin); + } + // Less than a day old, and more than an hour old + else if (hourDiff >= 1) { + const roundedHour = Math.round(hourDiff); + if (roundedHour === 1) fbDate = 'about an hour ago'; + else fbDate = `${roundedHour} hours ago`; + } + // Less than an hour, and more than a minute + else if (minDiff >= 1) { + const roundedMin = Math.round(minDiff); + if (roundedMin === 1) fbDate = 'about a minute ago'; + else fbDate = `${roundedMin} minutes ago`; + } + // Less than a minute + else if (minDiff < 1) { + fbDate = 'less than a minute ago'; + } + + // Update this element + $(this).html(fbDate); + $(this).attr('title', fullDate); + } catch (e) { + // Do nothing + } + }); + } +} + +export default TimeUtils; diff --git a/web/api-common/app-global.js b/web/api-common/app-global.js new file mode 100644 index 00000000..a0761552 --- /dev/null +++ b/web/api-common/app-global.js @@ -0,0 +1,184 @@ +var uploadId=""; +var uploadAttr=""; +var popupUpload = null; + +function showUploadDialog(id,msg,group,user,postUploadId,postUploadAttr,postUploadResultAttr,fileType){ + var ts = Math.round((new Date()).getTime() / 1000); + uploadId = postUploadId; + uploadAttr = postUploadAttr; + uploadResultAttr = postUploadResultAttr; + var html='
    '; + var html = html.replace(/_id_/g,id); + var html = html.replace(/_msg_/g,msg); + var html = html.replace(/_file_group_/g,group); + var html = html.replace(/_user_/g,user); + var html = html.replace(/_file_type_/g,fileType); + + modJs.renderModel('upload',"Upload File",html); + $('#uploadModel').modal('show'); + +} + +function closeUploadDialog(success,error,data){ + var arr = data.split("|"); + var file = arr[0]; + var fileBaseName = arr[1]; + var fileId = arr[2]; + + if(success == 1){ + //popupUpload.close(); + $('#uploadModel').modal('hide'); + if(uploadResultAttr == "url"){ + if(uploadAttr == "val"){ + $('#'+uploadId).val(file); + }else if(uploadAttr == "html"){ + $('#'+uploadId).html(file); + }else{ + $('#'+uploadId).attr(uploadAttr,file); + } + + }else if(uploadResultAttr == "name"){ + if(uploadAttr == "val"){ + $('#'+uploadId).val(fileBaseName); + }else if(uploadAttr == "html"){ + $('#'+uploadId).html(fileBaseName); + $('#'+uploadId).attr("val",fileBaseName); + }else{ + $('#'+uploadId).attr(uploadAttr,fileBaseName); + } + $('#'+uploadId).show(); + $('#'+uploadId+"_download").show(); + $('#'+uploadId+"_remove").show(); + }else if(uploadResultAttr == "id"){ + if(uploadAttr == "val"){ + $('#'+uploadId).attr(uploadAttr,fileId); + }else if(uploadAttr == "html"){ + $('#'+uploadId).html(fileBaseName); + $('#'+uploadId).attr("val",fileId); + }else{ + $('#'+uploadId).attr(uploadAttr,fileId); + } + $('#'+uploadId).show(); + $('#'+uploadId+"_download").show(); + $('#'+uploadId+"_remove").show(); + } + + + }else{ + //popupUpload.close(); + $('#uploadModel').modal('hide'); + } + +} + +function download(name, closeCallback, closeCallbackData){ + + var successCallback = function(data){ + + var link; + var fileParts; + var viewableImages = ["png","jpg","gif","bmp","jpge"]; + var viewableFiles = ["pdf","xml"]; + + $('.modal').modal('hide'); + + if(data['filename'].indexOf("https:") == 0 || data['filename'].indexOf("http:") == 0){ + fileParts = data['filename'].split("?"); + fileParts = fileParts[0].split("."); + + if(jQuery.inArray(fileParts[fileParts.length - 1], viewableFiles ) >= 0) { + var win = window.open(data['filename'], '_blank'); + win.focus(); + }else{ + link = 'Download File '; + if(jQuery.inArray(fileParts[fileParts.length - 1], viewableImages ) >= 0) { + link += '

    '; + } + modJs.showMessage("Download File Attachment",link,closeCallback,closeCallbackData); + } + }else{ + fileParts = data['filename'].split("."); + link = 'Download File '; + if(jQuery.inArray(fileParts[fileParts.length - 1], viewableImages ) >= 0) { + link += '

    '; + } + + modJs.showMessage("Download File Attachment",link,closeCallback,closeCallbackData); + } + + + }; + + var failCallback = function(data){ + modJs.showMessage("Error Downloading File","File not found"); + }; + + modJs.sendCustomRequest("file",{'name':name},successCallback,failCallback); +} + +function randomString(length){ + var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''); + + if (! length) { + length = Math.floor(Math.random() * chars.length); + } + + var str = ''; + for (var i = 0; i < length; i++) { + str += chars[Math.floor(Math.random() * chars.length)]; + } + return str; +} + +function verifyInstance(key){ + var object = {}; + object['a'] = "verifyInstance"; + object['key'] = key; + $.post(this.baseUrl, object, function(data) { + if(data.status == "SUCCESS"){ + $("#verifyModel").hide(); + $('body').removeClass('modal-open'); + $('.modal-backdrop').remove(); + alert("Success: Instance Verified"); + }else{ + alert("Error: "+data.message); + } + },"json"); +} + +function nl2br(str, is_xhtml) { + // discuss at: http://phpjs.org/functions/nl2br/ + // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: Philip Peterson + // improved by: Onno Marsman + // improved by: Atli ��r + // improved by: Brett Zamir (http://brett-zamir.me) + // improved by: Maximusya + // bugfixed by: Onno Marsman + // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // input by: Brett Zamir (http://brett-zamir.me) + // example 1: nl2br('Kevin\nvan\nZonneveld'); + // returns 1: 'Kevin
    \nvan
    \nZonneveld' + // example 2: nl2br("\nOne\nTwo\n\nThree\n", false); + // returns 2: '
    \nOne
    \nTwo
    \n
    \nThree
    \n' + // example 3: nl2br("\nOne\nTwo\n\nThree\n", true); + // returns 3: '
    \nOne
    \nTwo
    \n
    \nThree
    \n' + + var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '
    ' : '
    '; // Adjust comment to avoid issue on phpjs.org display + + return (str + '') + .replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2'); +} + +function updateLanguage(language) { + var object = {}; + object['a'] = "updateLanguage"; + object['language'] = language; + $.post(this.baseUrl, object, function(data) { + if(data.status == "SUCCESS"){ + location.reload(); + } else { + alert("Error occurred while changing language"); + } + },"json"); +} diff --git a/web/api-common/datatables/dataTables.bootstrap.js b/web/api-common/datatables/dataTables.bootstrap.js new file mode 100644 index 00000000..87b317c7 --- /dev/null +++ b/web/api-common/datatables/dataTables.bootstrap.js @@ -0,0 +1,250 @@ +/* Set the defaults for DataTables initialisation */ +$.extend( true, $.fn.dataTable.defaults, { + "sDom": + "<'row'<'col-xs-6'l><'col-xs-6'f>r>"+ + "t"+ + "<'row'<'col-xs-6'i><'col-xs-6'p>>", + "oLanguage": { + "sLengthMenu": "_MENU_ records per page" + } +} ); + + +/* Default class modification */ +$.extend( $.fn.dataTableExt.oStdClasses, { + "sWrapper": "dataTables_wrapper form-inline", + "sFilterInput": "form-control input-sm", + "sLengthSelect": "form-control input-sm" +} ); + +// In 1.10 we use the pagination renderers to draw the Bootstrap paging, +// rather than custom plug-in +if ( $.fn.dataTable.Api ) { + $.fn.dataTable.defaults.renderer = 'bootstrap'; + $.fn.dataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) { + var api = new $.fn.dataTable.Api( settings ); + var classes = settings.oClasses; + var lang = settings.oLanguage.oPaginate; + var btnDisplay, btnClass; + + var attach = function( container, buttons ) { + var i, ien, node, button; + var clickHandler = function ( e ) { + e.preventDefault(); + if ( e.data.action !== 'ellipsis' ) { + api.page( e.data.action ).draw( false ); + } + }; + + for ( i=0, ien=buttons.length ; i 0 ? + '' : ' disabled'); + break; + + case 'previous': + btnDisplay = lang.sPrevious; + btnClass = button + (page > 0 ? + '' : ' disabled'); + break; + + case 'next': + btnDisplay = lang.sNext; + btnClass = button + (page < pages-1 ? + '' : ' disabled'); + break; + + case 'last': + btnDisplay = lang.sLast; + btnClass = button + (page < pages-1 ? + '' : ' disabled'); + break; + + default: + btnDisplay = button + 1; + btnClass = page === button ? + 'active' : ''; + break; + } + + if ( btnDisplay ) { + node = $('
  • ', { + 'class': classes.sPageButton+' '+btnClass, + 'aria-controls': settings.sTableId, + 'tabindex': settings.iTabIndex, + 'id': idx === 0 && typeof button === 'string' ? + settings.sTableId +'_'+ button : + null + } ) + .append( $('', { + 'href': '#' + } ) + .html( btnDisplay ) + ) + .appendTo( container ); + + settings.oApi._fnBindAction( + node, {action: button}, clickHandler + ); + } + } + } + }; + + attach( + $(host).empty().html('
      ').children('ul'), + buttons + ); + } +} +else { + // Integration for 1.9- + $.fn.dataTable.defaults.sPaginationType = 'bootstrap'; + + /* API method to get paging information */ + $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) + { + return { + "iStart": oSettings._iDisplayStart, + "iEnd": oSettings.fnDisplayEnd(), + "iLength": oSettings._iDisplayLength, + "iTotal": oSettings.fnRecordsTotal(), + "iFilteredTotal": oSettings.fnRecordsDisplay(), + "iPage": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), + "iTotalPages": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) + }; + }; + + /* Bootstrap style pagination control */ + $.extend( $.fn.dataTableExt.oPagination, { + "bootstrap": { + "fnInit": function( oSettings, nPaging, fnDraw ) { + var oLang = oSettings.oLanguage.oPaginate; + var fnClickHandler = function ( e ) { + e.preventDefault(); + if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { + fnDraw( oSettings ); + } + }; + + $(nPaging).append( + '' + ); + var els = $('a', nPaging); + $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); + $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); + }, + + "fnUpdate": function ( oSettings, fnDraw ) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); + + if ( oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } + else if ( oPaging.iPage <= iHalf ) { + iStart = 1; + iEnd = iListLength; + } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + for ( i=0, ien=an.length ; i'+j+'') + .insertBefore( $('li:last', an[i])[0] ) + .bind('click', function (e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; + fnDraw( oSettings ); + } ); + } + + // Add / remove disabled classes from the static elements + if ( oPaging.iPage === 0 ) { + $('li:first', an[i]).addClass('disabled'); + } else { + $('li:first', an[i]).removeClass('disabled'); + } + + if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { + $('li:last', an[i]).addClass('disabled'); + } else { + $('li:last', an[i]).removeClass('disabled'); + } + } + } + } + } ); +} + + +/* + * TableTools Bootstrap compatibility + * Required TableTools 2.1+ + */ +if ( $.fn.DataTable.TableTools ) { + // Set the classes that TableTools uses to something suitable for Bootstrap + $.extend( true, $.fn.DataTable.TableTools.classes, { + "container": "DTTT btn-group", + "buttons": { + "normal": "btn btn-default", + "disabled": "disabled" + }, + "collection": { + "container": "DTTT_dropdown dropdown-menu", + "buttons": { + "normal": "", + "disabled": "disabled" + } + }, + "print": { + "info": "DTTT_print_info modal" + }, + "select": { + "row": "active" + } + } ); + + // Have the collection use a bootstrap compatible dropdown + $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { + "collection": { + "container": "ul", + "button": "li", + "liner": "a" + } + } ); +} \ No newline at end of file diff --git a/web/api-common/datatables/jquery.dataTables.js b/web/api-common/datatables/jquery.dataTables.js new file mode 100644 index 00000000..0d7e3748 --- /dev/null +++ b/web/api-common/datatables/jquery.dataTables.js @@ -0,0 +1,12131 @@ +/** + * @summary DataTables + * @description Paginate, search and sort HTML tables + * @version 1.9.4 + * @file jquery.dataTables.js + * @author Allan Jardine (www.sprymedia.co.uk) + * @contact www.sprymedia.co.uk/contact + * + * @copyright Copyright 2008-2012 Allan Jardine, all rights reserved. + * + * This source file is free software, under either the GPL v2 license or a + * BSD style license, available at: + * http://datatables.net/license_gpl2 + * http://datatables.net/license_bsd + * + * This source file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details. + * + * For details please refer to: http://www.datatables.net + */ + +/*jslint evil: true, undef: true, browser: true */ +/*globals $, jQuery,define,_fnExternApiFunc,_fnInitialise,_fnInitComplete,_fnLanguageCompat,_fnAddColumn,_fnColumnOptions,_fnAddData,_fnCreateTr,_fnGatherData,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnServerParams,_fnAddOptionsHtml,_fnFeatureHtmlTable,_fnScrollDraw,_fnAdjustColumnSizing,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnBuildSearchArray,_fnBuildSearchRow,_fnFilterCreateSearch,_fnDataToSearch,_fnSort,_fnSortAttachListener,_fnSortingClasses,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnFeatureHtmlLength,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnNodeToDataIndex,_fnVisbleColumns,_fnCalculateEnd,_fnConvertToWidth,_fnCalculateColumnWidths,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnDetectType,_fnSettingsFromNode,_fnGetDataMaster,_fnGetTrNodes,_fnGetTdNodes,_fnEscapeRegex,_fnDeleteIndex,_fnReOrderIndex,_fnColumnOrdering,_fnLog,_fnClearTable,_fnSaveState,_fnLoadState,_fnCreateCookie,_fnReadCookie,_fnDetectHeader,_fnGetUniqueThs,_fnScrollBarWidth,_fnApplyToChildren,_fnMap,_fnGetRowData,_fnGetCellData,_fnSetCellData,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnApplyColumnDefs,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnJsonString,_fnRender,_fnNodeToColumnIndex,_fnInfoMacros,_fnBrowserDetect,_fnGetColumns*/ + +(/** @lends */function( window, document, undefined ) { + +(function( factory ) { + "use strict"; + + // Define as an AMD module if possible + if ( typeof define === 'function' && define.amd ) + { + define( ['jquery'], factory ); + } + /* Define using browser globals otherwise + * Prevent multiple instantiations if the script is loaded twice + */ + else if ( jQuery && !jQuery.fn.dataTable ) + { + factory( jQuery ); + } +} +(/** @lends */function( $ ) { + "use strict"; + /** + * DataTables is a plug-in for the jQuery Javascript library. It is a + * highly flexible tool, based upon the foundations of progressive + * enhancement, which will add advanced interaction controls to any + * HTML table. For a full list of features please refer to + * DataTables.net. + * + * Note that the DataTable object is not a global variable but is + * aliased to jQuery.fn.DataTable and jQuery.fn.dataTable through which + * it may be accessed. + * + * @class + * @param {object} [oInit={}] Configuration object for DataTables. Options + * are defined by {@link DataTable.defaults} + * @requires jQuery 1.3+ + * + * @example + * // Basic initialisation + * $(document).ready( function { + * $('#example').dataTable(); + * } ); + * + * @example + * // Initialisation with configuration options - in this case, disable + * // pagination and sorting. + * $(document).ready( function { + * $('#example').dataTable( { + * "bPaginate": false, + * "bSort": false + * } ); + * } ); + */ + var DataTable = function( oInit ) + { + + + /** + * Add a column to the list used for the table with default values + * @param {object} oSettings dataTables settings object + * @param {node} nTh The th element for this column + * @memberof DataTable#oApi + */ + function _fnAddColumn( oSettings, nTh ) + { + var oDefaults = DataTable.defaults.columns; + var iCol = oSettings.aoColumns.length; + var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, { + "sSortingClass": oSettings.oClasses.sSortable, + "sSortingClassJUI": oSettings.oClasses.sSortJUI, + "nTh": nTh ? nTh : document.createElement('th'), + "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '', + "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol], + "mData": oDefaults.mData ? oDefaults.oDefaults : iCol + } ); + oSettings.aoColumns.push( oCol ); + + /* Add a column specific filter */ + if ( oSettings.aoPreSearchCols[ iCol ] === undefined || oSettings.aoPreSearchCols[ iCol ] === null ) + { + oSettings.aoPreSearchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch ); + } + else + { + var oPre = oSettings.aoPreSearchCols[ iCol ]; + + /* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */ + if ( oPre.bRegex === undefined ) + { + oPre.bRegex = true; + } + + if ( oPre.bSmart === undefined ) + { + oPre.bSmart = true; + } + + if ( oPre.bCaseInsensitive === undefined ) + { + oPre.bCaseInsensitive = true; + } + } + + /* Use the column options function to initialise classes etc */ + _fnColumnOptions( oSettings, iCol, null ); + } + + + /** + * Apply options for a column + * @param {object} oSettings dataTables settings object + * @param {int} iCol column index to consider + * @param {object} oOptions object with sType, bVisible and bSearchable etc + * @memberof DataTable#oApi + */ + function _fnColumnOptions( oSettings, iCol, oOptions ) + { + var oCol = oSettings.aoColumns[ iCol ]; + + /* User specified column options */ + if ( oOptions !== undefined && oOptions !== null ) + { + /* Backwards compatibility for mDataProp */ + if ( oOptions.mDataProp && !oOptions.mData ) + { + oOptions.mData = oOptions.mDataProp; + } + + if ( oOptions.sType !== undefined ) + { + oCol.sType = oOptions.sType; + oCol._bAutoType = false; + } + + $.extend( oCol, oOptions ); + _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" ); + + /* iDataSort to be applied (backwards compatibility), but aDataSort will take + * priority if defined + */ + if ( oOptions.iDataSort !== undefined ) + { + oCol.aDataSort = [ oOptions.iDataSort ]; + } + _fnMap( oCol, oOptions, "aDataSort" ); + } + + /* Cache the data get and set functions for speed */ + var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null; + var mData = _fnGetObjectDataFn( oCol.mData ); + var headers = modJs.getHeaders(); + oCol.fnGetData = function (oData, sSpecific) { + var modData = []; + for (var index in oData) { + if (oData.hasOwnProperty(index) && headers[index] && headers[index]['translate']) { + modData[index] = modJs.gt(oData[index]); + } else { + modData[index] = oData[index]; + } + } + var innerData = mData( modData, sSpecific ); + + if ( oCol.mRender && (sSpecific && sSpecific !== '') ) + { + return mRender( innerData, sSpecific, modData ); + } + return innerData; + }; + oCol.fnSetData = _fnSetObjectDataFn( oCol.mData ); + + /* Feature sorting overrides column specific when off */ + if ( !oSettings.oFeatures.bSort ) + { + oCol.bSortable = false; + } + + /* Check that the class assignment is correct for sorting */ + if ( !oCol.bSortable || + ($.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1) ) + { + oCol.sSortingClass = oSettings.oClasses.sSortableNone; + oCol.sSortingClassJUI = ""; + } + else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) == -1 ) + { + oCol.sSortingClass = oSettings.oClasses.sSortable; + oCol.sSortingClassJUI = oSettings.oClasses.sSortJUI; + } + else if ( $.inArray('asc', oCol.asSorting) != -1 && $.inArray('desc', oCol.asSorting) == -1 ) + { + oCol.sSortingClass = oSettings.oClasses.sSortableAsc; + oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIAscAllowed; + } + else if ( $.inArray('asc', oCol.asSorting) == -1 && $.inArray('desc', oCol.asSorting) != -1 ) + { + oCol.sSortingClass = oSettings.oClasses.sSortableDesc; + oCol.sSortingClassJUI = oSettings.oClasses.sSortJUIDescAllowed; + } + } + + + /** + * Adjust the table column widths for new data. Note: you would probably want to + * do a redraw after calling this function! + * @param {object} oSettings dataTables settings object + * @memberof DataTable#oApi + */ + function _fnAdjustColumnSizing ( oSettings ) + { + /* Not interested in doing column width calculation if auto-width is disabled */ + if ( oSettings.oFeatures.bAutoWidth === false ) + { + return false; + } + + _fnCalculateColumnWidths( oSettings ); + for ( var i=0 , iLen=oSettings.aoColumns.length ; i
  • ')[0]; + oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable ); + + /* + * All DataTables are wrapped in a div + */ + oSettings.nTableWrapper = $('
    ')[0]; + oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling; + + /* Track where we want to insert the option */ + var nInsertNode = oSettings.nTableWrapper; + + /* Loop over the user set positioning and place the elements as needed */ + var aDom = oSettings.sDom.split(''); + var nTmp, iPushFeature, cOption, nNewNode, cNext, sAttr, j; + for ( var i=0 ; i')[0]; + + /* Check to see if we should append an id and/or a class name to the container */ + cNext = aDom[i+1]; + if ( cNext == "'" || cNext == '"' ) + { + sAttr = ""; + j = 2; + while ( aDom[i+j] != cNext ) + { + sAttr += aDom[i+j]; + j++; + } + + /* Replace jQuery UI constants */ + if ( sAttr == "H" ) + { + sAttr = oSettings.oClasses.sJUIHeader; + } + else if ( sAttr == "F" ) + { + sAttr = oSettings.oClasses.sJUIFooter; + } + + /* The attribute can be in the format of "#id.class", "#id" or "class" This logic + * breaks the string into parts and applies them as needed + */ + if ( sAttr.indexOf('.') != -1 ) + { + var aSplit = sAttr.split('.'); + nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1); + nNewNode.className = aSplit[1]; + } + else if ( sAttr.charAt(0) == "#" ) + { + nNewNode.id = sAttr.substr(1, sAttr.length-1); + } + else + { + nNewNode.className = sAttr; + } + + i += j; /* Move along the position array */ + } + + nInsertNode.appendChild( nNewNode ); + nInsertNode = nNewNode; + } + else if ( cOption == '>' ) + { + /* End container div */ + nInsertNode = nInsertNode.parentNode; + } + else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange ) + { + /* Length */ + nTmp = _fnFeatureHtmlLength( oSettings ); + iPushFeature = 1; + } + else if ( cOption == 'f' && oSettings.oFeatures.bFilter ) + { + /* Filter */ + nTmp = _fnFeatureHtmlFilter( oSettings ); + iPushFeature = 1; + } + else if ( cOption == 'r' && oSettings.oFeatures.bProcessing ) + { + /* pRocessing */ + nTmp = _fnFeatureHtmlProcessing( oSettings ); + iPushFeature = 1; + } + else if ( cOption == 't' ) + { + /* Table */ + nTmp = _fnFeatureHtmlTable( oSettings ); + iPushFeature = 1; + } + else if ( cOption == 'i' && oSettings.oFeatures.bInfo ) + { + /* Info */ + nTmp = _fnFeatureHtmlInfo( oSettings ); + iPushFeature = 1; + } + else if ( cOption == 'p' && oSettings.oFeatures.bPaginate ) + { + /* Pagination */ + nTmp = _fnFeatureHtmlPaginate( oSettings ); + iPushFeature = 1; + } + else if ( DataTable.ext.aoFeatures.length !== 0 ) + { + /* Plug-in features */ + var aoFeatures = DataTable.ext.aoFeatures; + for ( var k=0, kLen=aoFeatures.length ; k') : + sSearchStr==="" ? '' : sSearchStr+' '; + + var nFilter = document.createElement( 'div' ); + nFilter.className = oSettings.oClasses.sFilter; + nFilter.innerHTML = ''; + if ( !oSettings.aanFeatures.f ) + { + nFilter.id = oSettings.sTableId+'_filter'; + } + + var jqFilter = $('input[type="text"]', nFilter); + + // Store a reference to the input element, so other input elements could be + // added to the filter wrapper if needed (submit button for example) + nFilter._DT_Input = jqFilter[0]; + + jqFilter.val( oPreviousSearch.sSearch.replace('"','"') ); + jqFilter.bind( 'keyup.DT', function(e) { + /* Update all other filter input elements for the new display */ + var n = oSettings.aanFeatures.f; + var val = this.value==="" ? "" : this.value; // mental IE8 fix :-( + + for ( var i=0, iLen=n.length ; i=0 ; i-- ) + { + var sData = _fnDataToSearch( _fnGetCellData( oSettings, oSettings.aiDisplay[i], iColumn, 'filter' ), + oSettings.aoColumns[iColumn].sType ); + if ( ! rpSearch.test( sData ) ) + { + oSettings.aiDisplay.splice( i, 1 ); + iIndexCorrector++; + } + } + } + + + /** + * Filter the data table based on user input and draw the table + * @param {object} oSettings dataTables settings object + * @param {string} sInput string to filter on + * @param {int} iForce optional - force a research of the master array (1) or not (undefined or 0) + * @param {bool} bRegex treat as a regular expression or not + * @param {bool} bSmart perform smart filtering or not + * @param {bool} bCaseInsensitive Do case insenstive matching or not + * @memberof DataTable#oApi + */ + function _fnFilter( oSettings, sInput, iForce, bRegex, bSmart, bCaseInsensitive ) + { + var i; + var rpSearch = _fnFilterCreateSearch( sInput, bRegex, bSmart, bCaseInsensitive ); + var oPrevSearch = oSettings.oPreviousSearch; + + /* Check if we are forcing or not - optional parameter */ + if ( !iForce ) + { + iForce = 0; + } + + /* Need to take account of custom filtering functions - always filter */ + if ( DataTable.ext.afnFiltering.length !== 0 ) + { + iForce = 1; + } + + /* + * If the input is blank - we want the full data set + */ + if ( sInput.length <= 0 ) + { + oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length); + oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); + } + else + { + /* + * We are starting a new search or the new search string is smaller + * then the old one (i.e. delete). Search from the master array + */ + if ( oSettings.aiDisplay.length == oSettings.aiDisplayMaster.length || + oPrevSearch.sSearch.length > sInput.length || iForce == 1 || + sInput.indexOf(oPrevSearch.sSearch) !== 0 ) + { + /* Nuke the old display array - we are going to rebuild it */ + oSettings.aiDisplay.splice( 0, oSettings.aiDisplay.length); + + /* Force a rebuild of the search array */ + _fnBuildSearchArray( oSettings, 1 ); + + /* Search through all records to populate the search array + * The the oSettings.aiDisplayMaster and asDataSearch arrays have 1 to 1 + * mapping + */ + for ( i=0 ; i').html(sSearch).text(); + } + + // Strip newline characters + return sSearch.replace( /[\n\r]/g, " " ); + } + + /** + * Build a regular expression object suitable for searching a table + * @param {string} sSearch string to search for + * @param {bool} bRegex treat as a regular expression or not + * @param {bool} bSmart perform smart filtering or not + * @param {bool} bCaseInsensitive Do case insensitive matching or not + * @returns {RegExp} constructed object + * @memberof DataTable#oApi + */ + function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive ) + { + var asSearch, sRegExpString; + + if ( bSmart ) + { + /* Generate the regular expression to use. Something along the lines of: + * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$ + */ + asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' ); + sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$'; + return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" ); + } + else + { + sSearch = bRegex ? sSearch : _fnEscapeRegex( sSearch ); + return new RegExp( sSearch, bCaseInsensitive ? "i" : "" ); + } + } + + + /** + * Convert raw data into something that the user can search on + * @param {string} sData data to be modified + * @param {string} sType data type + * @returns {string} search string + * @memberof DataTable#oApi + */ + function _fnDataToSearch ( sData, sType ) + { + if ( typeof DataTable.ext.ofnSearch[sType] === "function" ) + { + return DataTable.ext.ofnSearch[sType]( sData ); + } + else if ( sData === null ) + { + return ''; + } + else if ( sType == "html" ) + { + return sData.replace(/[\r\n]/g," ").replace( /<.*?>/g, "" ); + } + else if ( typeof sData === "string" ) + { + return sData.replace(/[\r\n]/g," "); + } + return sData; + } + + + /** + * scape a string such that it can be used in a regular expression + * @param {string} sVal string to escape + * @returns {string} escaped string + * @memberof DataTable#oApi + */ + function _fnEscapeRegex ( sVal ) + { + var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ]; + var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' ); + return sVal.replace(reReplace, '\\$1'); + } + + + /** + * Generate the node required for the info display + * @param {object} oSettings dataTables settings object + * @returns {node} Information element + * @memberof DataTable#oApi + */ + function _fnFeatureHtmlInfo ( oSettings ) + { + var nInfo = document.createElement( 'div' ); + nInfo.className = oSettings.oClasses.sInfo; + + /* Actions that are to be taken once only for this feature */ + if ( !oSettings.aanFeatures.i ) + { + /* Add draw callback */ + oSettings.aoDrawCallback.push( { + "fn": _fnUpdateInfo, + "sName": "information" + } ); + + /* Add id */ + nInfo.id = oSettings.sTableId+'_info'; + } + oSettings.nTable.setAttribute( 'aria-describedby', oSettings.sTableId+'_info' ); + + return nInfo; + } + + + /** + * Update the information elements in the display + * @param {object} oSettings dataTables settings object + * @memberof DataTable#oApi + */ + function _fnUpdateInfo ( oSettings ) + { + /* Show information about the table */ + if ( !oSettings.oFeatures.bInfo || oSettings.aanFeatures.i.length === 0 ) + { + return; + } + + var + oLang = oSettings.oLanguage, + iStart = oSettings._iDisplayStart+1, + iEnd = oSettings.fnDisplayEnd(), + iMax = oSettings.fnRecordsTotal(), + iTotal = oSettings.fnRecordsDisplay(), + sOut; + + if ( iTotal === 0 ) + { + /* Empty record set */ + sOut = oLang.sInfoEmpty; + } + else { + /* Normal record set */ + sOut = oLang.sInfo; + } + + if ( iTotal != iMax ) + { + /* Record set after filtering */ + sOut += ' ' + oLang.sInfoFiltered; + } + + // Convert the macros + sOut += oLang.sInfoPostFix; + sOut = _fnInfoMacros( oSettings, sOut ); + + if ( oLang.fnInfoCallback !== null ) + { + sOut = oLang.fnInfoCallback.call( oSettings.oInstance, + oSettings, iStart, iEnd, iMax, iTotal, sOut ); + } + + var n = oSettings.aanFeatures.i; + for ( var i=0, iLen=n.length ; i'; + var i, iLen; + var aLengthMenu = oSettings.aLengthMenu; + + if ( aLengthMenu.length == 2 && typeof aLengthMenu[0] === 'object' && + typeof aLengthMenu[1] === 'object' ) + { + for ( i=0, iLen=aLengthMenu[0].length ; i'+aLengthMenu[1][i]+''; + } + } + else + { + for ( i=0, iLen=aLengthMenu.length ; i'+aLengthMenu[i]+''; + } + } + sStdMenu += ''; + + var nLength = document.createElement( 'div' ); + if ( !oSettings.aanFeatures.l ) + { + nLength.id = oSettings.sTableId+'_length'; + } + nLength.className = oSettings.oClasses.sLength; + nLength.innerHTML = ''; + + /* + * Set the length to the current display length - thanks to Andrea Pavlovic for this fix, + * and Stefan Skopnik for fixing the fix! + */ + $('select option[value="'+oSettings._iDisplayLength+'"]', nLength).attr("selected", true); + + $('select', nLength).bind( 'change.DT', function(e) { + var iVal = $(this).val(); + + /* Update all other length options for the new display */ + var n = oSettings.aanFeatures.l; + for ( i=0, iLen=n.length ; i oSettings.aiDisplay.length || + oSettings._iDisplayLength == -1 ) + { + oSettings._iDisplayEnd = oSettings.aiDisplay.length; + } + else + { + oSettings._iDisplayEnd = oSettings._iDisplayStart + oSettings._iDisplayLength; + } + } + } + + + + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Note that most of the paging logic is done in + * DataTable.ext.oPagination + */ + + /** + * Generate the node required for default pagination + * @param {object} oSettings dataTables settings object + * @returns {node} Pagination feature node + * @memberof DataTable#oApi + */ + function _fnFeatureHtmlPaginate ( oSettings ) + { + if ( oSettings.oScroll.bInfinite ) + { + return null; + } + + var nPaginate = document.createElement( 'div' ); + nPaginate.className = oSettings.oClasses.sPaging+oSettings.sPaginationType; + + DataTable.ext.oPagination[ oSettings.sPaginationType ].fnInit( oSettings, nPaginate, + function( oSettings ) { + _fnCalculateEnd( oSettings ); + _fnDraw( oSettings ); + } + ); + + /* Add a draw callback for the pagination on first instance, to update the paging display */ + if ( !oSettings.aanFeatures.p ) + { + oSettings.aoDrawCallback.push( { + "fn": function( oSettings ) { + DataTable.ext.oPagination[ oSettings.sPaginationType ].fnUpdate( oSettings, function( oSettings ) { + _fnCalculateEnd( oSettings ); + _fnDraw( oSettings ); + } ); + }, + "sName": "pagination" + } ); + } + return nPaginate; + } + + + /** + * Alter the display settings to change the page + * @param {object} oSettings dataTables settings object + * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last" + * or page number to jump to (integer) + * @returns {bool} true page has changed, false - no change (no effect) eg 'first' on page 1 + * @memberof DataTable#oApi + */ + function _fnPageChange ( oSettings, mAction ) + { + var iOldStart = oSettings._iDisplayStart; + + if ( typeof mAction === "number" ) + { + oSettings._iDisplayStart = mAction * oSettings._iDisplayLength; + if ( oSettings._iDisplayStart > oSettings.fnRecordsDisplay() ) + { + oSettings._iDisplayStart = 0; + } + } + else if ( mAction == "first" ) + { + oSettings._iDisplayStart = 0; + } + else if ( mAction == "previous" ) + { + oSettings._iDisplayStart = oSettings._iDisplayLength>=0 ? + oSettings._iDisplayStart - oSettings._iDisplayLength : + 0; + + /* Correct for under-run */ + if ( oSettings._iDisplayStart < 0 ) + { + oSettings._iDisplayStart = 0; + } + } + else if ( mAction == "next" ) + { + if ( oSettings._iDisplayLength >= 0 ) + { + /* Make sure we are not over running the display array */ + if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() ) + { + oSettings._iDisplayStart += oSettings._iDisplayLength; + } + } + else + { + oSettings._iDisplayStart = 0; + } + } + else if ( mAction == "last" ) + { + if ( oSettings._iDisplayLength >= 0 ) + { + var iPages = parseInt( (oSettings.fnRecordsDisplay()-1) / oSettings._iDisplayLength, 10 ) + 1; + oSettings._iDisplayStart = (iPages-1) * oSettings._iDisplayLength; + } + else + { + oSettings._iDisplayStart = 0; + } + } + else + { + _fnLog( oSettings, 0, "Unknown paging action: "+mAction ); + } + $(oSettings.oInstance).trigger('page', oSettings); + + return iOldStart != oSettings._iDisplayStart; + } + + + + /** + * Generate the node required for the processing node + * @param {object} oSettings dataTables settings object + * @returns {node} Processing element + * @memberof DataTable#oApi + */ + function _fnFeatureHtmlProcessing ( oSettings ) + { + var nProcessing = document.createElement( 'div' ); + + if ( !oSettings.aanFeatures.r ) + { + nProcessing.id = oSettings.sTableId+'_processing'; + } + nProcessing.innerHTML = oSettings.oLanguage.sProcessing; + nProcessing.className = oSettings.oClasses.sProcessing; + oSettings.nTable.parentNode.insertBefore( nProcessing, oSettings.nTable ); + + return nProcessing; + } + + + /** + * Display or hide the processing indicator + * @param {object} oSettings dataTables settings object + * @param {bool} bShow Show the processing indicator (true) or not (false) + * @memberof DataTable#oApi + */ + function _fnProcessingDisplay ( oSettings, bShow ) + { + if ( oSettings.oFeatures.bProcessing ) + { + var an = oSettings.aanFeatures.r; + for ( var i=0, iLen=an.length ; i 0 ) + { + nCaption = nCaption[0]; + if ( nCaption._captionSide === "top" ) + { + nScrollHeadTable.appendChild( nCaption ); + } + else if ( nCaption._captionSide === "bottom" && nTfoot ) + { + nScrollFootTable.appendChild( nCaption ); + } + } + + /* + * Sizing + */ + /* When x-scrolling add the width and a scroller to move the header with the body */ + if ( oSettings.oScroll.sX !== "" ) + { + nScrollHead.style.width = _fnStringToCss( oSettings.oScroll.sX ); + nScrollBody.style.width = _fnStringToCss( oSettings.oScroll.sX ); + + if ( nTfoot !== null ) + { + nScrollFoot.style.width = _fnStringToCss( oSettings.oScroll.sX ); + } + + /* When the body is scrolled, then we also want to scroll the headers */ + $(nScrollBody).scroll( function (e) { + nScrollHead.scrollLeft = this.scrollLeft; + + if ( nTfoot !== null ) + { + nScrollFoot.scrollLeft = this.scrollLeft; + } + } ); + } + + /* When yscrolling, add the height */ + if ( oSettings.oScroll.sY !== "" ) + { + nScrollBody.style.height = _fnStringToCss( oSettings.oScroll.sY ); + } + + /* Redraw - align columns across the tables */ + oSettings.aoDrawCallback.push( { + "fn": _fnScrollDraw, + "sName": "scrolling" + } ); + + /* Infinite scrolling event handlers */ + if ( oSettings.oScroll.bInfinite ) + { + $(nScrollBody).scroll( function() { + /* Use a blocker to stop scrolling from loading more data while other data is still loading */ + if ( !oSettings.bDrawing && $(this).scrollTop() !== 0 ) + { + /* Check if we should load the next data set */ + if ( $(this).scrollTop() + $(this).height() > + $(oSettings.nTable).height() - oSettings.oScroll.iLoadGap ) + { + /* Only do the redraw if we have to - we might be at the end of the data */ + if ( oSettings.fnDisplayEnd() < oSettings.fnRecordsDisplay() ) + { + _fnPageChange( oSettings, 'next' ); + _fnCalculateEnd( oSettings ); + _fnDraw( oSettings ); + } + } + } + } ); + } + + oSettings.nScrollHead = nScrollHead; + oSettings.nScrollFoot = nScrollFoot; + + return nScroller; + } + + + /** + * Update the various tables for resizing. It's a bit of a pig this function, but + * basically the idea to: + * 1. Re-create the table inside the scrolling div + * 2. Take live measurements from the DOM + * 3. Apply the measurements + * 4. Clean up + * @param {object} o dataTables settings object + * @returns {node} Node to add to the DOM + * @memberof DataTable#oApi + */ + function _fnScrollDraw ( o ) + { + var + nScrollHeadInner = o.nScrollHead.getElementsByTagName('div')[0], + nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0], + nScrollBody = o.nTable.parentNode, + i, iLen, j, jLen, anHeadToSize, anHeadSizers, anFootSizers, anFootToSize, oStyle, iVis, + nTheadSize, nTfootSize, + iWidth, aApplied=[], aAppliedFooter=[], iSanityWidth, + nScrollFootInner = (o.nTFoot !== null) ? o.nScrollFoot.getElementsByTagName('div')[0] : null, + nScrollFootTable = (o.nTFoot !== null) ? nScrollFootInner.getElementsByTagName('table')[0] : null, + ie67 = o.oBrowser.bScrollOversize, + zeroOut = function(nSizer) { + oStyle = nSizer.style; + oStyle.paddingTop = "0"; + oStyle.paddingBottom = "0"; + oStyle.borderTopWidth = "0"; + oStyle.borderBottomWidth = "0"; + oStyle.height = 0; + }; + + /* + * 1. Re-create the table inside the scrolling div + */ + + /* Remove the old minimised thead and tfoot elements in the inner table */ + $(o.nTable).children('thead, tfoot').remove(); + + /* Clone the current header and footer elements and then place it into the inner table */ + nTheadSize = $(o.nTHead).clone()[0]; + o.nTable.insertBefore( nTheadSize, o.nTable.childNodes[0] ); + anHeadToSize = o.nTHead.getElementsByTagName('tr'); + anHeadSizers = nTheadSize.getElementsByTagName('tr'); + + if ( o.nTFoot !== null ) + { + nTfootSize = $(o.nTFoot).clone()[0]; + o.nTable.insertBefore( nTfootSize, o.nTable.childNodes[1] ); + anFootToSize = o.nTFoot.getElementsByTagName('tr'); + anFootSizers = nTfootSize.getElementsByTagName('tr'); + } + + /* + * 2. Take live measurements from the DOM - do not alter the DOM itself! + */ + + /* Remove old sizing and apply the calculated column widths + * Get the unique column headers in the newly created (cloned) header. We want to apply the + * calculated sizes to this header + */ + if ( o.oScroll.sX === "" ) + { + nScrollBody.style.width = '100%'; + nScrollHeadInner.parentNode.style.width = '100%'; + } + + var nThs = _fnGetUniqueThs( o, nTheadSize ); + for ( i=0, iLen=nThs.length ; i nScrollBody.offsetHeight || + $(nScrollBody).css('overflow-y') == "scroll") ) + { + o.nTable.style.width = _fnStringToCss( $(o.nTable).outerWidth() - o.oScroll.iBarWidth); + } + } + else + { + if ( o.oScroll.sXInner !== "" ) + { + /* x scroll inner has been given - use it */ + o.nTable.style.width = _fnStringToCss(o.oScroll.sXInner); + } + else if ( iSanityWidth == $(nScrollBody).width() && + $(nScrollBody).height() < $(o.nTable).height() ) + { + /* There is y-scrolling - try to take account of the y scroll bar */ + o.nTable.style.width = _fnStringToCss( iSanityWidth-o.oScroll.iBarWidth ); + if ( $(o.nTable).outerWidth() > iSanityWidth-o.oScroll.iBarWidth ) + { + /* Not possible to take account of it */ + o.nTable.style.width = _fnStringToCss( iSanityWidth ); + } + } + else + { + /* All else fails */ + o.nTable.style.width = _fnStringToCss( iSanityWidth ); + } + } + + /* Recalculate the sanity width - now that we've applied the required width, before it was + * a temporary variable. This is required because the column width calculation is done + * before this table DOM is created. + */ + iSanityWidth = $(o.nTable).outerWidth(); + + /* We want the hidden header to have zero height, so remove padding and borders. Then + * set the width based on the real headers + */ + + // Apply all styles in one pass. Invalidates layout only once because we don't read any + // DOM properties. + _fnApplyToChildren( zeroOut, anHeadSizers ); + + // Read all widths in next pass. Forces layout only once because we do not change + // any DOM properties. + _fnApplyToChildren( function(nSizer) { + aApplied.push( _fnStringToCss( $(nSizer).width() ) ); + }, anHeadSizers ); + + // Apply all widths in final pass. Invalidates layout only once because we do not + // read any DOM properties. + _fnApplyToChildren( function(nToSize, i) { + nToSize.style.width = aApplied[i]; + }, anHeadToSize ); + + $(anHeadSizers).height(0); + + /* Same again with the footer if we have one */ + if ( o.nTFoot !== null ) + { + _fnApplyToChildren( zeroOut, anFootSizers ); + + _fnApplyToChildren( function(nSizer) { + aAppliedFooter.push( _fnStringToCss( $(nSizer).width() ) ); + }, anFootSizers ); + + _fnApplyToChildren( function(nToSize, i) { + nToSize.style.width = aAppliedFooter[i]; + }, anFootToSize ); + + $(anFootSizers).height(0); + } + + /* + * 3. Apply the measurements + */ + + /* "Hide" the header and footer that we used for the sizing. We want to also fix their width + * to what they currently are + */ + _fnApplyToChildren( function(nSizer, i) { + nSizer.innerHTML = ""; + nSizer.style.width = aApplied[i]; + }, anHeadSizers ); + + if ( o.nTFoot !== null ) + { + _fnApplyToChildren( function(nSizer, i) { + nSizer.innerHTML = ""; + nSizer.style.width = aAppliedFooter[i]; + }, anFootSizers ); + } + + /* Sanity check that the table is of a sensible width. If not then we are going to get + * misalignment - try to prevent this by not allowing the table to shrink below its min width + */ + if ( $(o.nTable).outerWidth() < iSanityWidth ) + { + /* The min width depends upon if we have a vertical scrollbar visible or not */ + var iCorrection = ((nScrollBody.scrollHeight > nScrollBody.offsetHeight || + $(nScrollBody).css('overflow-y') == "scroll")) ? + iSanityWidth+o.oScroll.iBarWidth : iSanityWidth; + + /* IE6/7 are a law unto themselves... */ + if ( ie67 && (nScrollBody.scrollHeight > + nScrollBody.offsetHeight || $(nScrollBody).css('overflow-y') == "scroll") ) + { + o.nTable.style.width = _fnStringToCss( iCorrection-o.oScroll.iBarWidth ); + } + + /* Apply the calculated minimum width to the table wrappers */ + nScrollBody.style.width = _fnStringToCss( iCorrection ); + o.nScrollHead.style.width = _fnStringToCss( iCorrection ); + + if ( o.nTFoot !== null ) + { + o.nScrollFoot.style.width = _fnStringToCss( iCorrection ); + } + + /* And give the user a warning that we've stopped the table getting too small */ + if ( o.oScroll.sX === "" ) + { + _fnLog( o, 1, "The table cannot fit into the current element which will cause column"+ + " misalignment. The table has been drawn at its minimum possible width." ); + } + else if ( o.oScroll.sXInner !== "" ) + { + _fnLog( o, 1, "The table cannot fit into the current element which will cause column"+ + " misalignment. Increase the sScrollXInner value or remove it to allow automatic"+ + " calculation" ); + } + } + else + { + nScrollBody.style.width = _fnStringToCss( '100%' ); + o.nScrollHead.style.width = _fnStringToCss( '100%' ); + + if ( o.nTFoot !== null ) + { + o.nScrollFoot.style.width = _fnStringToCss( '100%' ); + } + } + + + /* + * 4. Clean up + */ + if ( o.oScroll.sY === "" ) + { + /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting + * the scrollbar height from the visible display, rather than adding it on. We need to + * set the height in order to sort this. Don't want to do it in any other browsers. + */ + if ( ie67 ) + { + nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+o.oScroll.iBarWidth ); + } + } + + if ( o.oScroll.sY !== "" && o.oScroll.bCollapse ) + { + nScrollBody.style.height = _fnStringToCss( o.oScroll.sY ); + + var iExtra = (o.oScroll.sX !== "" && o.nTable.offsetWidth > nScrollBody.offsetWidth) ? + o.oScroll.iBarWidth : 0; + if ( o.nTable.offsetHeight < nScrollBody.offsetHeight ) + { + nScrollBody.style.height = _fnStringToCss( o.nTable.offsetHeight+iExtra ); + } + } + + /* Finally set the width's of the header and footer tables */ + var iOuterWidth = $(o.nTable).outerWidth(); + nScrollHeadTable.style.width = _fnStringToCss( iOuterWidth ); + nScrollHeadInner.style.width = _fnStringToCss( iOuterWidth ); + + // Figure out if there are scrollbar present - if so then we need a the header and footer to + // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar) + var bScrolling = $(o.nTable).height() > nScrollBody.clientHeight || $(nScrollBody).css('overflow-y') == "scroll"; + nScrollHeadInner.style.paddingRight = bScrolling ? o.oScroll.iBarWidth+"px" : "0px"; + + if ( o.nTFoot !== null ) + { + nScrollFootTable.style.width = _fnStringToCss( iOuterWidth ); + nScrollFootInner.style.width = _fnStringToCss( iOuterWidth ); + nScrollFootInner.style.paddingRight = bScrolling ? o.oScroll.iBarWidth+"px" : "0px"; + } + + /* Adjust the position of the header in case we loose the y-scrollbar */ + $(nScrollBody).scroll(); + + /* If sorting or filtering has occurred, jump the scrolling back to the top */ + if ( o.bSorted || o.bFiltered ) + { + nScrollBody.scrollTop = 0; + } + } + + + /** + * Apply a given function to the display child nodes of an element array (typically + * TD children of TR rows + * @param {function} fn Method to apply to the objects + * @param array {nodes} an1 List of elements to look through for display children + * @param array {nodes} an2 Another list (identical structure to the first) - optional + * @memberof DataTable#oApi + */ + function _fnApplyToChildren( fn, an1, an2 ) + { + var index=0, i=0, iLen=an1.length; + var nNode1, nNode2; + + while ( i < iLen ) + { + nNode1 = an1[i].firstChild; + nNode2 = an2 ? an2[i].firstChild : null; + while ( nNode1 ) + { + if ( nNode1.nodeType === 1 ) + { + if ( an2 ) + { + fn( nNode1, nNode2, index ); + } + else + { + fn( nNode1, index ); + } + index++; + } + nNode1 = nNode1.nextSibling; + nNode2 = an2 ? nNode2.nextSibling : null; + } + i++; + } + } + + /** + * Convert a CSS unit width to pixels (e.g. 2em) + * @param {string} sWidth width to be converted + * @param {node} nParent parent to get the with for (required for relative widths) - optional + * @returns {int} iWidth width in pixels + * @memberof DataTable#oApi + */ + function _fnConvertToWidth ( sWidth, nParent ) + { + if ( !sWidth || sWidth === null || sWidth === '' ) + { + return 0; + } + + if ( !nParent ) + { + nParent = document.body; + } + + var iWidth; + var nTmp = document.createElement( "div" ); + nTmp.style.width = _fnStringToCss( sWidth ); + + nParent.appendChild( nTmp ); + iWidth = nTmp.offsetWidth; + nParent.removeChild( nTmp ); + + return ( iWidth ); + } + + + /** + * Calculate the width of columns for the table + * @param {object} oSettings dataTables settings object + * @memberof DataTable#oApi + */ + function _fnCalculateColumnWidths ( oSettings ) + { + var iTableWidth = oSettings.nTable.offsetWidth; + var iUserInputs = 0; + var iTmpWidth; + var iVisibleColumns = 0; + var iColums = oSettings.aoColumns.length; + var i, iIndex, iCorrector, iWidth; + var oHeaders = $('th', oSettings.nTHead); + var widthAttr = oSettings.nTable.getAttribute('width'); + var nWrapper = oSettings.nTable.parentNode; + + /* Convert any user input sizes into pixel sizes */ + for ( i=0 ; itd', nCalcTmp); + } + + /* Apply custom sizing to the cloned header */ + var nThs = _fnGetUniqueThs( oSettings, nTheadClone ); + iCorrector = 0; + for ( i=0 ; i 0 ) + { + oSettings.aoColumns[i].sWidth = _fnStringToCss( iWidth ); + } + iCorrector++; + } + } + + var cssWidth = $(nCalcTmp).css('width'); + oSettings.nTable.style.width = (cssWidth.indexOf('%') !== -1) ? + cssWidth : _fnStringToCss( $(nCalcTmp).outerWidth() ); + nCalcTmp.parentNode.removeChild( nCalcTmp ); + } + + if ( widthAttr ) + { + oSettings.nTable.style.width = _fnStringToCss( widthAttr ); + } + } + + + /** + * Adjust a table's width to take account of scrolling + * @param {object} oSettings dataTables settings object + * @param {node} n table node + * @memberof DataTable#oApi + */ + function _fnScrollingWidthAdjust ( oSettings, n ) + { + if ( oSettings.oScroll.sX === "" && oSettings.oScroll.sY !== "" ) + { + /* When y-scrolling only, we want to remove the width of the scroll bar so the table + * + scroll bar will fit into the area avaialble. + */ + var iOrigWidth = $(n).width(); + n.style.width = _fnStringToCss( $(n).outerWidth()-oSettings.oScroll.iBarWidth ); + } + else if ( oSettings.oScroll.sX !== "" ) + { + /* When x-scrolling both ways, fix the table at it's current size, without adjusting */ + n.style.width = _fnStringToCss( $(n).outerWidth() ); + } + } + + + /** + * Get the widest node + * @param {object} oSettings dataTables settings object + * @param {int} iCol column of interest + * @returns {node} widest table node + * @memberof DataTable#oApi + */ + function _fnGetWidestNode( oSettings, iCol ) + { + var iMaxIndex = _fnGetMaxLenString( oSettings, iCol ); + if ( iMaxIndex < 0 ) + { + return null; + } + + if ( oSettings.aoData[iMaxIndex].nTr === null ) + { + var n = document.createElement('td'); + n.innerHTML = _fnGetCellData( oSettings, iMaxIndex, iCol, '' ); + return n; + } + return _fnGetTdNodes(oSettings, iMaxIndex)[iCol]; + } + + + /** + * Get the maximum strlen for each data column + * @param {object} oSettings dataTables settings object + * @param {int} iCol column of interest + * @returns {string} max string length for each column + * @memberof DataTable#oApi + */ + function _fnGetMaxLenString( oSettings, iCol ) + { + var iMax = -1; + var iMaxIndex = -1; + + for ( var i=0 ; i/g, "" ); + if ( s.length > iMax ) + { + iMax = s.length; + iMaxIndex = i; + } + } + + return iMaxIndex; + } + + + /** + * Append a CSS unit (only if required) to a string + * @param {array} aArray1 first array + * @param {array} aArray2 second array + * @returns {int} 0 if match, 1 if length is different, 2 if no match + * @memberof DataTable#oApi + */ + function _fnStringToCss( s ) + { + if ( s === null ) + { + return "0px"; + } + + if ( typeof s == 'number' ) + { + if ( s < 0 ) + { + return "0px"; + } + return s+"px"; + } + + /* Check if the last character is not 0-9 */ + var c = s.charCodeAt( s.length-1 ); + if (c < 0x30 || c > 0x39) + { + return s; + } + return s+"px"; + } + + + /** + * Get the width of a scroll bar in this browser being used + * @returns {int} width in pixels + * @memberof DataTable#oApi + */ + function _fnScrollBarWidth () + { + var inner = document.createElement('p'); + var style = inner.style; + style.width = "100%"; + style.height = "200px"; + style.padding = "0px"; + + var outer = document.createElement('div'); + style = outer.style; + style.position = "absolute"; + style.top = "0px"; + style.left = "0px"; + style.visibility = "hidden"; + style.width = "200px"; + style.height = "150px"; + style.padding = "0px"; + style.overflow = "hidden"; + outer.appendChild(inner); + + document.body.appendChild(outer); + var w1 = inner.offsetWidth; + outer.style.overflow = 'scroll'; + var w2 = inner.offsetWidth; + if ( w1 == w2 ) + { + w2 = outer.clientWidth; + } + + document.body.removeChild(outer); + return (w1 - w2); + } + + /** + * Change the order of the table + * @param {object} oSettings dataTables settings object + * @param {bool} bApplyClasses optional - should we apply classes or not + * @memberof DataTable#oApi + */ + function _fnSort ( oSettings, bApplyClasses ) + { + var + i, iLen, j, jLen, k, kLen, + sDataType, nTh, + aaSort = [], + aiOrig = [], + oSort = DataTable.ext.oSort, + aoData = oSettings.aoData, + aoColumns = oSettings.aoColumns, + oAria = oSettings.oLanguage.oAria; + + /* No sorting required if server-side or no sorting array */ + if ( !oSettings.oFeatures.bServerSide && + (oSettings.aaSorting.length !== 0 || oSettings.aaSortingFixed !== null) ) + { + aaSort = ( oSettings.aaSortingFixed !== null ) ? + oSettings.aaSortingFixed.concat( oSettings.aaSorting ) : + oSettings.aaSorting.slice(); + + /* If there is a sorting data type, and a function belonging to it, then we need to + * get the data from the developer's function and apply it for this column + */ + for ( i=0 ; i/g, "" ); + nTh = aoColumns[i].nTh; + nTh.removeAttribute('aria-sort'); + nTh.removeAttribute('aria-label'); + + /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */ + if ( aoColumns[i].bSortable ) + { + if ( aaSort.length > 0 && aaSort[0][0] == i ) + { + nTh.setAttribute('aria-sort', aaSort[0][1]=="asc" ? "ascending" : "descending" ); + + var nextSort = (aoColumns[i].asSorting[ aaSort[0][2]+1 ]) ? + aoColumns[i].asSorting[ aaSort[0][2]+1 ] : aoColumns[i].asSorting[0]; + nTh.setAttribute('aria-label', sTitle+ + (nextSort=="asc" ? oAria.sSortAscending : oAria.sSortDescending) ); + } + else + { + nTh.setAttribute('aria-label', sTitle+ + (aoColumns[i].asSorting[0]=="asc" ? oAria.sSortAscending : oAria.sSortDescending) ); + } + } + else + { + nTh.setAttribute('aria-label', sTitle); + } + } + + /* Tell the draw function that we have sorted the data */ + oSettings.bSorted = true; + $(oSettings.oInstance).trigger('sort', oSettings); + + /* Copy the master data into the draw array and re-draw */ + if ( oSettings.oFeatures.bFilter ) + { + /* _fnFilter() will redraw the table for us */ + _fnFilterComplete( oSettings, oSettings.oPreviousSearch, 1 ); + } + else + { + oSettings.aiDisplay = oSettings.aiDisplayMaster.slice(); + oSettings._iDisplayStart = 0; /* reset display back to page 0 */ + _fnCalculateEnd( oSettings ); + _fnDraw( oSettings ); + } + } + + + /** + * Attach a sort handler (click) to a node + * @param {object} oSettings dataTables settings object + * @param {node} nNode node to attach the handler to + * @param {int} iDataIndex column sorting index + * @param {function} [fnCallback] callback function + * @memberof DataTable#oApi + */ + function _fnSortAttachListener ( oSettings, nNode, iDataIndex, fnCallback ) + { + _fnBindAction( nNode, {}, function (e) { + /* If the column is not sortable - don't to anything */ + if ( oSettings.aoColumns[iDataIndex].bSortable === false ) + { + return; + } + + /* + * This is a little bit odd I admit... I declare a temporary function inside the scope of + * _fnBuildHead and the click handler in order that the code presented here can be used + * twice - once for when bProcessing is enabled, and another time for when it is + * disabled, as we need to perform slightly different actions. + * Basically the issue here is that the Javascript engine in modern browsers don't + * appear to allow the rendering engine to update the display while it is still executing + * it's thread (well - it does but only after long intervals). This means that the + * 'processing' display doesn't appear for a table sort. To break the js thread up a bit + * I force an execution break by using setTimeout - but this breaks the expected + * thread continuation for the end-developer's point of view (their code would execute + * too early), so we only do it when we absolutely have to. + */ + var fnInnerSorting = function () { + modJs.sortingStarted(1); + var iColumn, iNextSort; + + /* If the shift key is pressed then we are multiple column sorting */ + if ( e.shiftKey ) + { + /* Are we already doing some kind of sort on this column? */ + var bFound = false; + for ( var i=0 ; i 0 && sCurrentClass.indexOf(sNewClass) == -1 ) + { + /* We need to add a class */ + nTds[i].className = sCurrentClass + " " + sNewClass; + } + } + } + } + + + + /** + * Save the state of a table in a cookie such that the page can be reloaded + * @param {object} oSettings dataTables settings object + * @memberof DataTable#oApi + */ + function _fnSaveState ( oSettings ) + { + if ( !oSettings.oFeatures.bStateSave || oSettings.bDestroying ) + { + return; + } + + /* Store the interesting variables */ + var i, iLen, bInfinite=oSettings.oScroll.bInfinite; + var oState = { + "iCreate": new Date().getTime(), + "iStart": (bInfinite ? 0 : oSettings._iDisplayStart), + "iEnd": (bInfinite ? oSettings._iDisplayLength : oSettings._iDisplayEnd), + "iLength": oSettings._iDisplayLength, + "aaSorting": $.extend( true, [], oSettings.aaSorting ), + "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ), + "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ), + "abVisCols": [] + }; + + for ( i=0, iLen=oSettings.aoColumns.length ; i 4096 ) /* Magic 10 for padding */ + { + for ( var i=0, iLen=aCookies.length ; i 4096 ) { + if ( aOldCookies.length === 0 ) { + // Deleted all DT cookies and still not enough space. Can't state save + return; + } + + var old = aOldCookies.pop(); + document.cookie = old.name+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path="+ + aParts.join('/') + "/"; + } + } + + document.cookie = sFullCookie; + } + + + /** + * Read an old cookie to get a cookie with an old table state + * @param {string} sName name of the cookie to read + * @returns {string} contents of the cookie - or null if no cookie with that name found + * @memberof DataTable#oApi + */ + function _fnReadCookie ( sName ) + { + var + aParts = window.location.pathname.split('/'), + sNameEQ = sName + '_' + aParts[aParts.length-1].replace(/[\/:]/g,"").toLowerCase() + '=', + sCookieContents = document.cookie.split(';'); + + for( var i=0 ; i=0 ; i-- ) + { + aRet.push( aoStore[i].fn.apply( oSettings.oInstance, aArgs ) ); + } + + if ( sTrigger !== null ) + { + $(oSettings.oInstance).trigger(sTrigger, aArgs); + } + + return aRet; + } + + + /** + * JSON stringify. If JSON.stringify it provided by the browser, json2.js or any other + * library, then we use that as it is fast, safe and accurate. If the function isn't + * available then we need to built it ourselves - the inspiration for this function comes + * from Craig Buckler ( http://www.sitepoint.com/javascript-json-serialization/ ). It is + * not perfect and absolutely should not be used as a replacement to json2.js - but it does + * do what we need, without requiring a dependency for DataTables. + * @param {object} o JSON object to be converted + * @returns {string} JSON string + * @memberof DataTable#oApi + */ + var _fnJsonString = (window.JSON) ? JSON.stringify : function( o ) + { + /* Not an object or array */ + var sType = typeof o; + if (sType !== "object" || o === null) + { + // simple data type + if (sType === "string") + { + o = '"'+o+'"'; + } + return o+""; + } + + /* If object or array, need to recurse over it */ + var + sProp, mValue, + json = [], + bArr = $.isArray(o); + + for (sProp in o) + { + mValue = o[sProp]; + sType = typeof mValue; + + if (sType === "string") + { + mValue = '"'+mValue+'"'; + } + else if (sType === "object" && mValue !== null) + { + mValue = _fnJsonString(mValue); + } + + json.push((bArr ? "" : '"'+sProp+'":') + mValue); + } + + return (bArr ? "[" : "{") + json + (bArr ? "]" : "}"); + }; + + + /** + * From some browsers (specifically IE6/7) we need special handling to work around browser + * bugs - this function is used to detect when these workarounds are needed. + * @param {object} oSettings dataTables settings object + * @memberof DataTable#oApi + */ + function _fnBrowserDetect( oSettings ) + { + /* IE6/7 will oversize a width 100% element inside a scrolling element, to include the + * width of the scrollbar, while other browsers ensure the inner element is contained + * without forcing scrolling + */ + var n = $( + '
    '+ + '
    '+ + '
    '+ + '
    '+ + '
    ')[0]; + + document.body.appendChild( n ); + oSettings.oBrowser.bScrollOversize = $('#DT_BrowserTest', n)[0].offsetWidth === 100 ? true : false; + document.body.removeChild( n ); + } + + + /** + * Perform a jQuery selector action on the table's TR elements (from the tbody) and + * return the resulting jQuery object. + * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on + * @param {object} [oOpts] Optional parameters for modifying the rows to be included + * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter + * criterion ("applied") or all TR elements (i.e. no filter). + * @param {string} [oOpts.order=current] Order of the TR elements in the processed array. + * Can be either 'current', whereby the current sorting of the table is used, or + * 'original' whereby the original order the data was read into the table is used. + * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page + * ("current") or not ("all"). If 'current' is given, then order is assumed to be + * 'current' and filter is 'applied', regardless of what they might be given as. + * @returns {object} jQuery object, filtered by the given selector. + * @dtopt API + * + * @example + * $(document).ready(function() { + * var oTable = $('#example').dataTable(); + * + * // Highlight every second row + * oTable.$('tr:odd').css('backgroundColor', 'blue'); + * } ); + * + * @example + * $(document).ready(function() { + * var oTable = $('#example').dataTable(); + * + * // Filter to rows with 'Webkit' in them, add a background colour and then + * // remove the filter, thus highlighting the 'Webkit' rows only. + * oTable.fnFilter('Webkit'); + * oTable.$('tr', {"filter": "applied"}).css('backgroundColor', 'blue'); + * oTable.fnFilter(''); + * } ); + */ + this.$ = function ( sSelector, oOpts ) + { + var i, iLen, a = [], tr; + var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); + var aoData = oSettings.aoData; + var aiDisplay = oSettings.aiDisplay; + var aiDisplayMaster = oSettings.aiDisplayMaster; + + if ( !oOpts ) + { + oOpts = {}; + } + + oOpts = $.extend( {}, { + "filter": "none", // applied + "order": "current", // "original" + "page": "all" // current + }, oOpts ); + + // Current page implies that order=current and fitler=applied, since it is fairly + // senseless otherwise + if ( oOpts.page == 'current' ) + { + for ( i=oSettings._iDisplayStart, iLen=oSettings.fnDisplayEnd() ; i + *
  • 1D array of data - add a single row with the data provided
  • + *
  • 2D array of arrays - add multiple rows in a single call
  • + *
  • object - data object when using mData
  • + *
  • array of objects - multiple data objects when using mData
  • + * + * @param {bool} [bRedraw=true] redraw the table or not + * @returns {array} An array of integers, representing the list of indexes in + * aoData ({@link DataTable.models.oSettings}) that have been added to + * the table. + * @dtopt API + * + * @example + * // Global var for counter + * var giCount = 2; + * + * $(document).ready(function() { + * $('#example').dataTable(); + * } ); + * + * function fnClickAddRow() { + * $('#example').dataTable().fnAddData( [ + * giCount+".1", + * giCount+".2", + * giCount+".3", + * giCount+".4" ] + * ); + * + * giCount++; + * } + */ + this.fnAddData = function( mData, bRedraw ) + { + if ( mData.length === 0 ) + { + return []; + } + + var aiReturn = []; + var iTest; + + /* Find settings from table node */ + var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); + + /* Check if we want to add multiple rows or not */ + if ( typeof mData[0] === "object" && mData[0] !== null ) + { + for ( var i=0 ; i= oSettings.fnRecordsDisplay() ) + { + oSettings._iDisplayStart -= oSettings._iDisplayLength; + if ( oSettings._iDisplayStart < 0 ) + { + oSettings._iDisplayStart = 0; + } + } + + if ( bRedraw === undefined || bRedraw ) + { + _fnCalculateEnd( oSettings ); + _fnDraw( oSettings ); + } + + return oData; + }; + + + /** + * Restore the table to it's original state in the DOM by removing all of DataTables + * enhancements, alterations to the DOM structure of the table and event listeners. + * @param {boolean} [bRemove=false] Completely remove the table from the DOM + * @dtopt API + * + * @example + * $(document).ready(function() { + * // This example is fairly pointless in reality, but shows how fnDestroy can be used + * var oTable = $('#example').dataTable(); + * oTable.fnDestroy(); + * } ); + */ + this.fnDestroy = function ( bRemove ) + { + var oSettings = _fnSettingsFromNode( this[DataTable.ext.iApiIndex] ); + var nOrig = oSettings.nTableWrapper.parentNode; + var nBody = oSettings.nTBody; + var i, iLen; + + bRemove = (bRemove===undefined) ? false : bRemove; + + /* Flag to note that the table is currently being destroyed - no action should be taken */ + oSettings.bDestroying = true; + + /* Fire off the destroy callbacks for plug-ins etc */ + _fnCallbackFire( oSettings, "aoDestroyCallback", "destroy", [oSettings] ); + + /* If the table is not being removed, restore the hidden columns */ + if ( !bRemove ) + { + for ( i=0, iLen=oSettings.aoColumns.length ; itr>td.'+oSettings.oClasses.sRowEmpty, oSettings.nTable).parent().remove(); + + /* When scrolling we had to break the table up - restore it */ + if ( oSettings.nTable != oSettings.nTHead.parentNode ) + { + $(oSettings.nTable).children('thead').remove(); + oSettings.nTable.appendChild( oSettings.nTHead ); + } + + if ( oSettings.nTFoot && oSettings.nTable != oSettings.nTFoot.parentNode ) + { + $(oSettings.nTable).children('tfoot').remove(); + oSettings.nTable.appendChild( oSettings.nTFoot ); + } + + /* Remove the DataTables generated nodes, events and classes */ + oSettings.nTable.parentNode.removeChild( oSettings.nTable ); + $(oSettings.nTableWrapper).remove(); + + oSettings.aaSorting = []; + oSettings.aaSortingFixed = []; + _fnSortingClasses( oSettings ); + + $(_fnGetTrNodes( oSettings )).removeClass( oSettings.asStripeClasses.join(' ') ); + + $('th, td', oSettings.nTHead).removeClass( [ + oSettings.oClasses.sSortable, + oSettings.oClasses.sSortableAsc, + oSettings.oClasses.sSortableDesc, + oSettings.oClasses.sSortableNone ].join(' ') + ); + if ( oSettings.bJUI ) + { + $('th span.'+oSettings.oClasses.sSortIcon + + ', td span.'+oSettings.oClasses.sSortIcon, oSettings.nTHead).remove(); + + $('th, td', oSettings.nTHead).each( function () { + var jqWrapper = $('div.'+oSettings.oClasses.sSortJUIWrapper, this); + var kids = jqWrapper.contents(); + $(this).append( kids ); + jqWrapper.remove(); + } ); + } + + /* Add the TR elements back into the table in their original order */ + if ( !bRemove && oSettings.nTableReinsertBefore ) + { + nOrig.insertBefore( oSettings.nTable, oSettings.nTableReinsertBefore ); + } + else if ( !bRemove ) + { + nOrig.appendChild( oSettings.nTable ); + } + + for ( i=0, iLen=oSettings.aoData.length ; i