PMCORE-2352 User extended attributes PMCORE-2247

This commit is contained in:
Roly Rudy Gutierrez Pinto
2020-12-16 19:47:59 -04:00
parent 9311905f74
commit d57a3ac932
65 changed files with 39216 additions and 153 deletions

View File

@@ -0,0 +1,24 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/nbproject/private/

View File

@@ -0,0 +1,24 @@
# my-app
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

View File

@@ -0,0 +1,233 @@
<?php
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Role;
use ProcessMaker\Model\UserExtendedAttributes;
global $G_PUBLISH;
$G_PUBLISH = new Publisher();
try {
$option = empty($_REQUEST["option"]) ? '' : $_REQUEST["option"];
switch ($option) {
case "list":
$rbacRoles = Role::getAllRoles();
$orders = [
"attributeName" => "UEA_NAME",
"attribute" => "UEA_ATTRIBUTE_ID",
"role" => "UEA_ROLES",
"dateCreated" => "UEA_DATE_CREATE"
];
$query = empty($_REQUEST["query"]) ? "" : $_REQUEST["query"];
$limit = empty($_REQUEST["limit"]) ? 10 : $_REQUEST["limit"];
$start = empty($_REQUEST["start"]) ? 0 : $_REQUEST["start"];
$ascending = !isset($_REQUEST["ascending"]) ? "1" : $_REQUEST["ascending"];
$orderBy = $orders["attributeName"];
if (!empty($_REQUEST["orderBy"]) && !empty($orders[$_REQUEST["orderBy"]])) {
$orderBy = $orders[$_REQUEST["orderBy"]];
}
$count = UserExtendedAttributes::join('USERS', 'USERS.USR_ID', '=', 'USER_EXTENDED_ATTRIBUTES.UEA_OWNER')
->count();
$userExtendedAttributes = UserExtendedAttributes::query()
->join('USERS', 'USERS.USR_ID', '=', 'USER_EXTENDED_ATTRIBUTES.UEA_OWNER')
->where('UEA_NAME', 'LIKE', "%{$query}%")
->orWhere('UEA_ATTRIBUTE_ID', 'LIKE', "%{$query}%")
->orWhere('UEA_ROLES', 'LIKE', "%{$query}%")
->orWhere('UEA_DATE_CREATE', 'LIKE', "%{$query}%")
->orderBy($orderBy, $ascending === "1" ? "asc" : "desc")
->offset($start)
->limit($limit)
->get()
->toArray();
//change key names
array_walk($userExtendedAttributes, function (&$row) use($rbacRoles) {
foreach ($row as $key => $value) {
$string = $key;
$string = strtolower($string);
$string = str_replace(["uea_"], "", $string);
$string = str_replace("_", " ", $string);
$string = ucwords($string);
$string = lcfirst($string);
$string = str_replace(" ", "", $string);
$row[$string] = $row[$key];
unset($row[$key]);
}
//format owner
$row["owner"] = $row["usrUsername"];
//format roles
$rolesLabel = [];
if (is_array($rbacRoles)) {
$roles = G::json_decode($row["roles"]);
foreach ($roles as $rol) {
foreach ($rbacRoles as $item) {
if (isset($item->ROL_CODE) && $rol === $item->ROL_CODE) {
$rolesLabel[] = $item->ROL_NAME;
}
}
}
}
$row["rolesLabel"] = $rolesLabel;
});
$result = [
"data" => $userExtendedAttributes,
"count" => $count
];
echo G::json_encode($result);
break;
case "userExtendedAttributesList":
$userExtendedAttributes = UserExtendedAttributes::query()
->orderBy('UEA_NAME')
->get()
->toArray();
//change key names
array_walk($userExtendedAttributes, function (&$row) {
foreach ($row as $key => $value) {
$string = $key;
$string = strtolower($string);
$string = str_replace(["uea_"], "", $string);
$string = str_replace("_", " ", $string);
$string = ucwords($string);
$string = lcfirst($string);
$string = str_replace(" ", "", $string);
$row[$string] = $row[$key];
unset($row[$key]);
}
});
$result = [
"data" => $userExtendedAttributes
];
echo json_encode($result);
break;
case "listByRol":
$rolCode = empty($_REQUEST["rolCode"]) ? "" : $_REQUEST["rolCode"];
$userExtendedAttributes = UserExtendedAttributes::query()
->Where("UEA_ROLES", 'LIKE', "%{$rolCode}%")
->orderBy("UEA_NAME", "asc")
->get()
->toArray();
$default = [
["value" => "USR_FIRSTNAME", "text" => "USR_FIRSTNAME", "extended" => false],
["value" => "USR_LASTNAME", "text" => "USR_LASTNAME", "extended" => false],
["value" => "USR_EMAIL", "text" => "USR_EMAIL", "extended" => false],
["value" => "USR_DUE_DATE", "text" => "USR_DUE_DATE", "extended" => false],
["value" => "USR_STATUS", "text" => "USR_STATUS", "extended" => false],
["value" => "USR_STATUS_ID", "text" => "USR_STATUS_ID", "extended" => false],
["value" => "USR_ADDRESS", "text" => "USR_ADDRESS", "extended" => false],
["value" => "USR_PHONE", "text" => "USR_PHONE", "extended" => false],
["value" => "USR_FAX", "text" => "USR_FAX", "extended" => false],
["value" => "USR_CELLULAR", "text" => "USR_CELLULAR", "extended" => false],
["value" => "USR_ZIP_CODE", "text" => "USR_ZIP_CODE", "extended" => false],
["value" => "USR_POSITION", "text" => "USR_POSITION", "extended" => false],
["value" => "USR_BIRTHDAY", "text" => "USR_BIRTHDAY", "extended" => false],
["value" => "USR_COST_BY_HOUR", "text" => "USR_COST_BY_HOUR", "extended" => false],
["value" => "USR_UNIT_COST", "text" => "USR_UNIT_COST", "extended" => false],
["value" => "USR_PMDRIVE_FOLDER_UID", "text" => "USR_PMDRIVE_FOLDER_UID", "extended" => false],
["value" => "USR_BOOKMARK_START_CASES", "text" => "USR_BOOKMARK_START_CASES", "extended" => false],
["value" => "USR_TIME_ZONE", "text" => "USR_TIME_ZONE", "extended" => false],
["value" => "USR_DEFAULT_LANG", "text" => "USR_DEFAULT_LANG", "extended" => false],
["value" => "USR_LAST_LOGIN", "text" => "USR_LAST_LOGIN", "extended" => false]
];
$data = [];
foreach ($userExtendedAttributes as $key => $value) {
$data[] = [
"value" => $value["UEA_ATTRIBUTE_ID"],
"text" => $value["UEA_NAME"],
"extended" => true
];
}
$data = array_merge($data, $default);
$result = [
"data" => $data
];
echo G::json_encode($result);
break;
case "save":
$userUid = empty($_SESSION['USER_LOGGED']) ? RBAC::ADMIN_USER_UID : $_SESSION['USER_LOGGED'];
$user = new Users();
$user = $user->load($userUid);
$userId = empty($user['USR_ID']) ? null : $user['USR_ID'];
$id = empty($_REQUEST["UEA_ID"]) ? "" : $_REQUEST["UEA_ID"];
$name = empty($_REQUEST["UEA_NAME"]) ? "" : $_REQUEST["UEA_NAME"];
$attributeId = empty($_REQUEST["UEA_ATTRIBUTE_ID"]) ? "" : $_REQUEST["UEA_ATTRIBUTE_ID"];
$hidden = empty($_REQUEST["UEA_HIDDEN"]) ? "" : $_REQUEST["UEA_HIDDEN"];
$required = empty($_REQUEST["UEA_REQUIRED"]) ? "" : $_REQUEST["UEA_REQUIRED"];
$password = empty($_REQUEST["UEA_PASSWORD"]) ? "" : $_REQUEST["UEA_PASSWORD"];
$option = empty($_REQUEST["UEA_OPTION"]) ? "" : $_REQUEST["UEA_OPTION"];
$roles = empty($_REQUEST["UEA_ROLES"]) ? "" : $_REQUEST["UEA_ROLES"];
$owner = empty($_REQUEST["UEA_OWNER"]) ? $userId : $_REQUEST["UEA_OWNER"];
$dateCreate = empty($_REQUEST["UEA_DATE_CREATE"]) ? date("Y-m-d H:i:s") : $_REQUEST["UEA_DATE_CREATE"];
$userExtendedAttributes = UserExtendedAttributes::where('UEA_ID', '=', $id)
->get()
->first();
if (empty($userExtendedAttributes)) {
$userExtendedAttributes = new UserExtendedAttributes();
}
$userExtendedAttributes->UEA_NAME = trim($name);
$userExtendedAttributes->UEA_ATTRIBUTE_ID = trim($attributeId);
$userExtendedAttributes->UEA_HIDDEN = $hidden;
$userExtendedAttributes->UEA_REQUIRED = $required;
$userExtendedAttributes->UEA_PASSWORD = $password;
$userExtendedAttributes->UEA_OPTION = $option;
$userExtendedAttributes->UEA_ROLES = $roles;
$userExtendedAttributes->UEA_OWNER = $owner;
$userExtendedAttributes->UEA_DATE_CREATE = $dateCreate;
$userExtendedAttributes->save();
echo G::json_encode($userExtendedAttributes);
break;
case "delete":
$id = empty($_REQUEST["id"]) ? "" : $_REQUEST["id"];
if (!empty($id)) {
$id = UserExtendedAttributes::where('UEA_ID', '=', $id)
->delete();
}
echo G::json_encode($id);
break;
case "verifyName":
$id = empty($_REQUEST["id"]) ? "" : $_REQUEST["id"];
$name = empty($_REQUEST["name"]) ? "" : $_REQUEST["name"];
$userExtendedAttributes = UserExtendedAttributes::query()
->where('UEA_NAME', '=', trim($name))
->where('UEA_ID', '<>', $id)
->get()
->first();
$result = [
"valid" => empty($userExtendedAttributes),
"message" => empty($userExtendedAttributes) ? "" : G::loadTranslation("ID_NAME_EXISTS")
];
echo G::json_encode($result);
break;
case "verifyAttributeId":
$id = empty($_REQUEST["id"]) ? "" : $_REQUEST["id"];
$attributeId = empty($_REQUEST["attributeId"]) ? "" : $_REQUEST["attributeId"];
$userExtendedAttributes = UserExtendedAttributes::query()
->where('UEA_ATTRIBUTE_ID', '=', trim($attributeId))
->where('UEA_ID', '<>', $id)
->get()
->first();
$result = [
"valid" => empty($userExtendedAttributes),
"message" => empty($userExtendedAttributes) ? "" : G::loadTranslation("ID_EXIST")
];
echo G::json_encode($result);
break;
default:
$conf = new Configurations();
$pageSize = $conf->getEnvSetting('casesListRowNumber');
$pageSize = empty($pageSize) ? 25 : $pageSize;
$lang = defined("SYS_LANG") ? SYS_LANG : "en";
$html = file_get_contents(PATH_HTML . "lib/userExtendedAttributes/index.html");
$html = str_replace("var pageSize=10;", "var pageSize={$pageSize};", $html);
$html = str_replace("translation.en.js", "translation.{$lang}.js", $html);
echo $html;
break;
}
} catch (Exception $e) {
$message = [
'MESSAGE' => $e->getMessage()
];
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $message);
G::RenderPage('publish', 'blank');
}

View File

@@ -0,0 +1,4 @@
file.reference.userExtendedAttributes-public=public
files.encoding=UTF-8
site.root.folder=${file.reference.userExtendedAttributes-public}
source.folder=

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.clientproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
<name>userExtendedAttributes</name>
</data>
</configuration>
</project>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
{
"name": "userExtendedAttributes",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --dest ../../../public_html/lib/userExtendedAttributes",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@panter/vue-i18next": "^0.15.2",
"@vue/cli": "^4.4.6",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"bootstrap-vue": "^2.20.1",
"core-js": "^3.8.1",
"lodash": "^4.17.19",
"save": "^2.4.0",
"vue": "^2.6.11",
"vue-tables-2": "^2.1.61",
"vuelidate": "^0.7.5"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.9",
"@vue/cli-plugin-eslint": "^4.5.9",
"@vue/cli-service": "^4.5.9",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
<!-- These are default values, then they are overridden when processmaker runs -->
<script type="text/javascript" src="/js/ext/translation.en.js"></script>
<script type="text/javascript">
var pageSize=10;
</script>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@@ -0,0 +1,67 @@
<template>
<div id="app">
<userExtendedAttributes ref="userExtendedAttributes"
v-show="views.userExtendedAttributes"
@newAttribute="newAttribute"
@editAttribute="editAttribute">
</userExtendedAttributes>
<newUserAttribute ref="newUserAttribute"
v-show="views.newUserAttribute"
@save="saveAttribute"
@cancel="cancel">
</newUserAttribute>
</div>
</template>
<script>
import userExtendedAttributes from './components/userExtendedAttributes.vue'
import newUserAttribute from './components/newUserAttribute.vue'
export default {
name: 'app',
components: {
userExtendedAttributes,
newUserAttribute
},
data() {
return {
views: {
userExtendedAttributes: true,
newUserAttribute: false
}
};
},
methods: {
showView(name) {
for (let view in this.views) {
this.views[view] = false;
}
this.views[name] = true;
},
cancel() {
this.showView("userExtendedAttributes");
},
newAttribute() {
this.$refs.newUserAttribute.reset();
this.showView("newUserAttribute");
},
saveAttribute() {
this.showView("userExtendedAttributes");
this.$refs.userExtendedAttributes.refresh();
},
editAttribute(row) {
this.$refs.newUserAttribute.reset();
this.$refs.newUserAttribute.load(row);
this.showView("newUserAttribute");
}
}
}
</script>
<style>
#app {
margin: 20px;
}
.custom-tooltip > .tooltip-inner{
max-width: none;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

@@ -0,0 +1,378 @@
<template>
<div>
<titleSection :title="$root.translation('ID_NEW_USER_ATTRIBUTE')"></titleSection>
<b-form @submit.stop.prevent="onsubmit">
<b-container fluid>
<b-row>
<b-col cols="6">
<b-form-group :label="$root.translation('ID_NAME')">
<b-form-input v-model="form.name"
autocomplete="off"
:state="statusName"
@keyup="validateName"/>
<b-form-invalid-feedback>{{statusNameMessage}}</b-form-invalid-feedback>
</b-form-group>
</b-col>
<b-col>
<b-form-group :label="$root.translation('ID_ATTRIBUTE_ID')">
<b-form-input v-model="form.attributeId"
autocomplete="off"
:state="statusAttributeId"
@keyup="validateAttributeId"/>
<b-form-invalid-feedback>{{statusAttributeIdMessage}}</b-form-invalid-feedback>
</b-form-group>
</b-col>
</b-row>
<b-row>
<b-col cols="6">
<b-form-group :label="$root.translation('ID_PROPERTIES')">
<b-form-checkbox v-model="form.hidden"
value="1"
unchecked-value="0"
:disabled="form.required===1 || form.password===1">
{{$root.translation('ID_HIDDEN')}}
<b-button variant="outline-light"
v-b-tooltip="{title:$root.translation('ID_ATTRIBUTE_WONT_BE_SEEN_IN_USER_INFORMATION'),placement:'right',variant:'warning',customClass:'custom-tooltip'}">
<b-icon icon="question-circle-fill"
aria-hidden="true"
variant="primary"/>
</b-button>
</b-form-checkbox>
<b-form-checkbox v-model="form.required"
value="1"
unchecked-value="0"
:disabled="form.hidden===1">
{{$root.translation('ID_REQUIRED')}}
<b-button variant="outline-light"
v-b-tooltip="{title:$root.translation('ID_ATTRIBUTE_WILL_BE_REQUIRED_WHEN_EDITING_USER_SETTINGS'),placement:'right',variant:'warning',customClass:'custom-tooltip'}">
<b-icon icon="question-circle-fill"
aria-hidden="true"
variant="primary"/>
</b-button>
</b-form-checkbox>
<b-form-checkbox v-model="form.password"
value="1"
unchecked-value="0"
:disabled="form.hidden===1">
{{$root.translation('ID_TYPE_PASSWORD')}}
<b-button variant="outline-light"
v-b-tooltip="{title:$root.translation('ID_ATTRIBUTE_WILL_BE_HIDDEN_USING_PLACEHOLDER'),placement:'right',variant:'warning',customClass:'custom-tooltip'}">
<b-icon icon="question-circle-fill"
aria-hidden="true"
variant="primary"/>
</b-button>
</b-form-checkbox>
</b-form-group>
</b-col>
<b-col>
</b-col>
</b-row>
<b-row class="bv-row-flex-cols">
<b-col cols="6">
<b-form-group :label="$root.translation('ID_PROPERTIES')">
<b-form-radio v-model="form.option"
value="allUser"
class="mt-2">
{{$root.translation('ID_ALL_USERS')}}
</b-form-radio>
<b-form-radio v-model="form.option"
value="byRol"
class="mt-3">
{{$root.translation('ID_BY_ROLE')}}
</b-form-radio>
</b-form-group>
</b-col>
<b-col cols="6" align-self="end">
<b-form-group>
<b-input-group>
<b-form-select v-model="form.rol"
:disabled="form.option==='allUser'"
:options="roles"></b-form-select>
<b-input-group-append>
<b-button variant="outline-secondary"
@click="refreshRoles"
:disabled="form.option==='allUser'">
<b-icon icon="arrow-repeat"
aria-hidden="true"/>
</b-button>
</b-input-group-append>
<b-input-group-append>
<b-button variant="success"
@click="addRole"
:disabled="form.option==='allUser'">
<b-icon icon="plus" aria-hidden="true"/> {{$root.translation('ID_ADD')}}
</b-button>
</b-input-group-append>
</b-input-group>
</b-form-group>
</b-col>
</b-row>
<b-row>
<b-col>
<b-form-group>
<b-form-tags v-model="form.selectedRoles"
style="min-height:55px"
:disabled="form.option==='allUser'">
<template v-slot="{ tags, inputAttrs, inputHandlers, tagVariant, addTag, removeTag, disabled}">
<!--important is the control body-->
<div class="d-inline-block">
<div v-for="tag in tags"
:key="tag"
:title="tag"
class="d-inline-block border bg-light rounded-lg p-1 mr-2">
{{getTextRol(tag)}}
<b-button size="sm"
variant="light"
:disabled="disabled"
@click="deleteRol(tag,function(){removeTag(tag);})">
<b-icon icon="x"
aria-hidden="true"
variant="primary"/>
</b-button>
</div>
</div>
</template>
</b-form-tags>
</b-form-group>
</b-col>
</b-row>
<b-row class="text-right">
<b-col>
<b-form-group>
<b-button variant="danger"
@click="$emit('cancel')">{{$root.translation('ID_CANCEL')}}</b-button>&nbsp;
<b-button type="submit"
variant="success"
:disabled="!statusValidation">{{$root.translation('ID_SAVE')}}</b-button>
</b-form-group>
</b-col>
</b-row>
</b-container>
</b-form>
</div>
</template>
<script>
import titleSection from "./titleSection.vue"
import axios from "axios"
import { validationMixin } from "vuelidate"
export default {
mixins: [validationMixin],
components: {
titleSection
},
data() {
return {
form: {
id: "",
name: "",
attributeId: "",
hidden: 0,
required: 0,
password: 0,
option: "allUser",
selectedRoles: [],
rol: "0"
},
roles: this.getRoles(),
statusValidation: true,
statusName: null,
statusNameMessage: "",
statusAttributeId: null,
statusAttributeIdMessage: ""
};
},
methods: {
reset() {
this.form = {
id: "",
name: "",
attributeId: "",
hidden: 0,
required: 0,
password: 0,
option: "allUser",
selectedRoles: [],
rol: "0"
};
this.statusValidation = true;
},
onsubmit() {
this.statusName = true;
if (this.form.name.trim() === "") {
this.statusName = false;
this.statusNameMessage = this.$root.translation("ID_IS_REQUIRED");
return;
}
this.statusAttributeId = true;
if (this.form.attributeId.trim() === "") {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_IS_REQUIRED");
return;
}
if (/^[a-zA-Z][_0-9a-zA-Z]+$/.test(this.form.attributeId) === false) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_INVALID_DATA");
return;
}
this.saveForm();
},
validateName() {
this.statusValidation = false;
let formData = new FormData();
formData.append("id", this.form.id);
formData.append("name", this.form.name);
return axios.post(this.$root.baseUrl() + "userExtendedAttributes/index?option=verifyName", formData)
.then(response => {
response;
if (response.data.valid === false) {
this.statusName = false;
this.statusNameMessage = response.data.message;
} else {
this.statusName = true;
this.statusValidation = true;
}
})
.catch(error => {
error;
})
.finally(() => {
});
},
validateAttributeId() {
this.statusValidation = false;
if (/^[a-zA-Z][_0-9a-zA-Z]+$/.test(this.form.attributeId) === false) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = this.$root.translation("ID_INVALID_DATA");
return;
}
let formData = new FormData();
formData.append("id", this.form.id);
formData.append("attributeId", this.form.attributeId);
return axios.post(this.$root.baseUrl() + "userExtendedAttributes/index?option=verifyAttributeId", formData)
.then(response => {
response;
if (response.data.valid === false) {
this.statusAttributeId = false;
this.statusAttributeIdMessage = response.data.message;
} else {
this.statusAttributeId = true;
this.statusValidation = true;
}
})
.catch(error => {
error;
})
.finally(() => {
});
},
saveForm() {
this.statusValidation = false;
let formData = this.formToFormData(this.form);
return axios.post(this.$root.baseUrl() + "userExtendedAttributes/index?option=save", formData)
.then(response => {
response;
this.$emit("save");
this.statusValidation = true;
})
.catch(error => {
error;
})
.finally(() => {
});
},
getRoles() {
this.refreshRoles();
return this.roles;
},
refreshRoles() {
let formData = new FormData();
formData.append("request", "allRoles");
axios.post(this.$root.baseUrl() + "roles/roles_Ajax", formData)
.then(response => {
response;
let data = [
{value: "0", text: this.$root.translation('ID_EMPTY_TYPE')}
];
for (let i in response.data) {
data.push({
value: response.data[i].ROL_CODE,
text: response.data[i].ROL_NAME
});
}
this.roles = data;
})
.catch(error => {
error;
})
.finally(() => {
});
},
addRole() {
if (this.form.rol === "0") {
return;
}
let obj = this.form.selectedRoles.find(rol => rol === this.form.rol);
if (obj !== undefined) {
return;
}
this.form.selectedRoles.push(this.form.rol);
},
getTextRol(tag) {
let obj = this.roles.find(rol => rol.value === tag);
return obj.text;
},
deleteRol(tag, process) {
this.$bvModal.msgBoxConfirm(this.$root.translation('ID_THE_USER_ROLES_FOR_ATTRIBUTE_HAS_BEEN_DELETED_PLEASE_CONFIRM', ['']), {
title: " ", //is important because title disappear
hideHeaderClose: false,
okTitle: this.$root.translation('ID_CONFIRM'),
okVariant: "success",
cancelTitle: this.$root.translation('ID_CANCEL'),
cancelVariant: "danger"
}).then(value => {
if (value === false) {
return;
}
process();
}).catch(err => {
err;
});
},
formToFormData(form) {
let formData = new FormData();
formData.append("UEA_ID", form.id);
formData.append("UEA_NAME", form.name);
formData.append("UEA_ATTRIBUTE_ID", form.attributeId);
formData.append("UEA_HIDDEN", form.hidden);
formData.append("UEA_REQUIRED", form.required);
formData.append("UEA_PASSWORD", form.password);
formData.append("UEA_OPTION", form.option);
formData.append("UEA_ROLES", JSON.stringify(form.selectedRoles));
return formData;
},
rowToForm(row) {
let form = {
id: row.id,
name: row.name,
attributeId: row.attributeId,
hidden: row.hidden,
required: row.required,
password: row.password,
option: row.option,
selectedRoles: JSON.parse(row.roles)
};
return form;
},
load(row) {
this.form = this.rowToForm(row);
}
}
}
</script>
<style scoped>
.bv-row-flex-cols{
min-height:7rem;
}
</style>

View File

@@ -0,0 +1,18 @@
<template>
<div>
<h3 class="text-primary">
{{title}}
</h3>
</div>
</template>
<script>
export default{
props: {
title: String
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,179 @@
<template>
<div>
<titleSection :title="$root.translation('ID_USER_EXTENDED_ATTRIBUTES')"></titleSection>
<b-form-group class="float-right">
<b-button variant="success"
@click="newAttribute">
<b-icon icon="plus" aria-hidden="true"/> {{$root.translation('ID_NEW_ATTRIBUTE')}}
</b-button>
</b-form-group>
<v-server-table ref="vServerTable1"
:url="$root.baseUrl()+'userExtendedAttributes/index?option=list'"
:columns="columns"
:options="options">
<div slot="roles"
slot-scope="props">
{{formatingRoles(props.row.rolesLabel)}}
</div>
<div slot="owner"
slot-scope="props">
{{props.row.owner}}
<b-avatar :id="'as-b-avatar-tooltip-'+props.index"
size="sm"
class="float-right">
</b-avatar>
<b-tooltip :target="'as-b-avatar-tooltip-'+props.index"
triggers="hover"
custom-class="custom-tooltip"
placement="right"
variant="info">
<b-container fluid>
<b-row class="text-left">
<b-col>
{{props.row.usrUsername}}<br>
{{props.row.usrFirstname}} {{props.row.usrLastname}}<br>
{{props.row.usrEmail}}<br>
{{props.row.usrFax}}<br>
{{props.row.usrCellular}}<br>
{{props.row.usrTimeZone}}<br>
</b-col>
<b-col>
<b-avatar size="lg"
variant="dark">
</b-avatar>
</b-col>
</b-row>
</b-container>
</b-tooltip>
</div>
<div slot="icons"
slot-scope="props">
<b-button-group>
<b-button :title="$root.translation('ID_EDIT_ATTRIBUTE')"
v-b-tooltip.hover
variant="light"
@click="editAttribute(props.row)">
<b-icon icon="pencil-fill" aria-hidden="true" variant="info"/>
</b-button>
<b-button :title="$root.translation('ID_DELETE_ATTRIBUTE')"
v-b-tooltip.hover
variant="light"
@click="deleteAttribute(props.row)">
<b-icon icon="trash" aria-hidden="true" variant="danger"/>
</b-button>
</b-button-group>
</div>
</v-server-table>
</div>
</template>
<script>
import titleSection from "./titleSection.vue"
import axios from "axios"
export default {
components: {
titleSection
},
data() {
return {
columns: [
"name",
"attributeId",
"roles",
"owner",
"dateCreate",
"icons"
],
options: {
headings: {
name: this.$root.translation('ID_ATTRIBUTE_NAME'),
attributeId: this.$root.translation('ID_ATTRIBUTE'),
roles: this.$root.translation('ID_ROLE'),
owner: this.$root.translation('ID_OWNER'),
dateCreate: this.$root.translation('ID_PRO_CREATE_DATE'),
icons: ""
},
sortable: [
"name",
"attributeId",
"roles",
"dateCreate"
],
filterable: [
"name",
"attributeId",
"roles",
"dateCreate"
],
texts: {
filter: "",
filterPlaceholder: this.$root.translation("ID_EMPTY_SEARCH"),
count: this.$root.translation("ID_SHOWING_FROM_RECORDS_COUNT"),
noResults: this.$root.translation("ID_NO_MATCHING_RECORDS"),
loading: this.$root.translation("ID_LOADING_GRID")
},
perPage: "pageSize" in window ? window.pageSize : 5,
perPageValues: [],
requestFunction(data) {
data.start = (data.page - 1) * data.limit;
return axios.get(this.url, {params: data}, {}).catch(function (e) {
this.dispatch("error", e);
});
},
responseAdapter(data) {
return {
data: data.data.data,
count: data.data.count
};
}
}
};
},
methods: {
newAttribute() {
this.$emit("newAttribute");
},
editAttribute(row) {
this.$emit("editAttribute", row);
},
deleteAttribute(row) {
this.$bvModal.msgBoxConfirm(this.$root.translation('ID_THE_ATTRIBUTE_WILL_BE_DELETED_PLEASE_CONFIRM', [row.name]), {
title: " ", //is important because title disappear
hideHeaderClose: false,
okTitle: this.$root.translation('ID_CONFIRM'),
okVariant: "success",
cancelTitle: this.$root.translation('ID_CANCEL'),
cancelVariant: "danger"
}).then(value => {
if (value === false) {
return;
}
let formData = new FormData();
formData.append("option", "delete");
formData.append("id", row.id);
axios.post(this.$root.baseUrl() + "userExtendedAttributes/index", formData)
.then(response => {
response;
this.refresh();
})
.catch(error => {
error;
})
.finally(() => {
});
}).catch(err => {
err;
});
},
refresh() {
this.$refs.vServerTable1.refresh();
},
formatingRoles(rolesLabel) {
return rolesLabel.join(", ");
}
}
}
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,33 @@
import Vue from 'vue'
import {BootstrapVue, IconsPlugin} from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
import {ClientTable} from 'vue-tables-2'
import {ServerTable} from 'vue-tables-2'
import App from './App.vue';
Vue.config.productionTip = false
Vue.use(BootstrapVue)
Vue.use(IconsPlugin)
Vue.use(ClientTable, {}, false, 'bootstrap4', {});
Vue.use(ServerTable, {}, false, 'bootstrap4', {});
new Vue({
render: h => h(App),
methods: {
translation(text, params) {
if ("TRANSLATIONS" in window && text in window.TRANSLATIONS) {
text = window.TRANSLATIONS[text];
if (params != undefined && "length" in params) {
for (let i = 0; i < params.length; i++) {
text = text.replace("{" + i + "}", params[i]);
}
}
}
return text;
},
baseUrl() {
return "../";
}
}
}).$mount('#app');

View File

@@ -0,0 +1,3 @@
module.exports = {
publicPath: '/lib/userExtendedAttributes/'
};