Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
e3b92131
Commit
e3b92131
authored
5 years ago
by
Johannes Hörmann
Committed by
Sophia Leierseder
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add task to employee-lib
parent
01217445
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
entity/ActivityLink_entity/ActivityLink_entity.aod
+2
-0
2 additions, 0 deletions
entity/ActivityLink_entity/ActivityLink_entity.aod
process/Employee_lib/process.js
+115
-112
115 additions, 112 deletions
process/Employee_lib/process.js
with
117 additions
and
112 deletions
entity/ActivityLink_entity/ActivityLink_entity.aod
+
2
−
0
View file @
e3b92131
...
...
@@ -16,6 +16,7 @@
<name>
OBJECT_TYPE
</name>
<title>
{$OBJECTLINK_TYPE}
</title>
<consumer>
Context
</consumer>
<mandatory
v=
"true"
/>
<displayValueProcess>
%aditoprj%/entity/ActivityLink_entity/entityfields/object_type/displayValueProcess.js
</displayValueProcess>
</entityField>
<entityField>
...
...
@@ -23,6 +24,7 @@
<title>
{$OBJECTLINK_OBJECT}
</title>
<consumer>
Objects
</consumer>
<linkedContextProcess>
%aditoprj%/entity/ActivityLink_entity/entityfields/object_rowid/linkedContextProcess.js
</linkedContextProcess>
<mandatory
v=
"true"
/>
<displayValueProcess>
%aditoprj%/entity/ActivityLink_entity/entityfields/object_rowid/displayValueProcess.js
</displayValueProcess>
</entityField>
<entityField>
...
...
This diff is collapsed.
Click to expand it.
process/Employee_lib/process.js
+
115
−
112
View file @
e3b92131
import
(
"
system.db
"
);
import
(
"
Sql_lib
"
);
import
(
"
system.tools
"
);
/**
* Provides functions for employees and users.j
*
* Do not create an instance of this!
*
* @class
*/
function
EmployeeUtils
()
{}
/**
* Returns the contact id of the current user
*
* @return the contact id
*/
EmployeeUtils
.
getCurrentContactId
=
function
()
{
var
user
=
tools
.
getCurrentUser
();
return
user
?
user
[
tools
.
PARAMS
][
tools
.
CONTACTID
]
:
null
;
}
/**
* Returns the username id of the current user
*
* @return the username
*/
EmployeeUtils
.
getCurrentUserName
=
function
()
{
var
user
=
tools
.
getCurrentUser
();
return
user
?
user
[
tools
.
TITLE
]
:
null
;
}
EmployeeUtils
.
sliceUserId
=
function
(
pUserId
)
{
return
pUserId
.
substr
(
10
,
36
);
}
/**
* generates a username from the firstname and lastname with the given structure
*
* @param {String} pFirstName
* @param {String} pLastName
* @param {String} pStructure the structure of the username, special characters:
* f - one letter of the firstname in lowercase
* F - one letter of the firstname in uppsercase
* l - one letter of the lastname in lowercase
* L - one letter of the lastname in uppsercase
* f+ - the complete firstname in lowercase
* F+ - the complete firstname
* l+ - the complete lastname in lowercae
* L+ - the complete lastname
*
* @return {String} the generated username
*/
EmployeeUtils
.
generateUserName
=
function
(
pFirstName
,
pLastName
,
pStructure
)
{
if
(
!
pStructure
||
(
!
pFirstName
&&
!
pLastName
))
return
null
;
var
firstNameIndex
=
0
;
var
lastNameIndex
=
0
;
var
userName
=
pStructure
.
replace
(
/
(
f
\+
|l
\+
|f|l
)
/ig
,
function
(
type
)
{
switch
(
type
)
{
case
"
f+
"
:
return
pFirstName
.
toLowerCase
()
||
""
;
case
"
F+
"
:
return
pFirstName
||
""
;
case
"
l+
"
:
return
pLastName
.
toLowerCase
()
||
""
;
case
"
L+
"
:
return
pLastName
||
""
;
case
"
f
"
:
return
pFirstName
.
charAt
(
firstNameIndex
++
).
toLowerCase
()
||
""
;
case
"
F
"
:
return
pFirstName
.
charAt
(
firstNameIndex
++
).
toUpperCase
()
||
""
;
case
"
l
"
:
return
pLastName
.
charAt
(
lastNameIndex
++
).
toLowerCase
()
||
""
;
case
"
L
"
:
return
pLastName
.
charAt
(
lastNameIndex
++
).
toUpperCase
()
||
""
;
}
});
return
userName
;
}
/**
* checks if an employee is used somewhere
*
* @param {String} pContactId the contact id of the user
*
* @return {boolean} if the employee has relations
*/
EmployeeUtils
.
hasRelations
=
function
(
pContactId
)
{
//sql queries with selects on tables where an employee can be used
var
queries
=
[
SqlCondition
.
begin
()
.
andPrepare
(
"
ACTIVITY.CREATOR
"
,
pContactId
)
.
buildSql
(
"
select 1 from ACTIVITY
"
),
SqlCondition
.
begin
()
.
andPrepare
(
"
TIMETRACKING.CONTACT_ID
"
,
pContactId
)
.
buildSql
(
"
select 1 from TIMETRACKING
"
)
];
return
queries
.
some
(
function
(
sql
)
{
return
db
.
cell
(
sql
)
!=
""
;
});
import
(
"
system.db
"
);
import
(
"
Sql_lib
"
);
import
(
"
system.tools
"
);
/**
* Provides functions for employees and users.j
*
* Do not create an instance of this!
*
* @class
*/
function
EmployeeUtils
()
{}
/**
* Returns the contact id of the current user
*
* @return the contact id
*/
EmployeeUtils
.
getCurrentContactId
=
function
()
{
var
user
=
tools
.
getCurrentUser
();
return
user
?
user
[
tools
.
PARAMS
][
tools
.
CONTACTID
]
:
null
;
}
/**
* Returns the username id of the current user
*
* @return the username
*/
EmployeeUtils
.
getCurrentUserName
=
function
()
{
var
user
=
tools
.
getCurrentUser
();
return
user
?
user
[
tools
.
TITLE
]
:
null
;
}
EmployeeUtils
.
sliceUserId
=
function
(
pUserId
)
{
return
pUserId
.
substr
(
10
,
36
);
}
/**
* generates a username from the firstname and lastname with the given structure
*
* @param {String} pFirstName
* @param {String} pLastName
* @param {String} pStructure the structure of the username, special characters:
* f - one letter of the firstname in lowercase
* F - one letter of the firstname in uppsercase
* l - one letter of the lastname in lowercase
* L - one letter of the lastname in uppsercase
* f+ - the complete firstname in lowercase
* F+ - the complete firstname
* l+ - the complete lastname in lowercae
* L+ - the complete lastname
*
* @return {String} the generated username
*/
EmployeeUtils
.
generateUserName
=
function
(
pFirstName
,
pLastName
,
pStructure
)
{
if
(
!
pStructure
||
(
!
pFirstName
&&
!
pLastName
))
return
null
;
var
firstNameIndex
=
0
;
var
lastNameIndex
=
0
;
var
userName
=
pStructure
.
replace
(
/
(
f
\+
|l
\+
|f|l
)
/ig
,
function
(
type
)
{
switch
(
type
)
{
case
"
f+
"
:
return
pFirstName
.
toLowerCase
()
||
""
;
case
"
F+
"
:
return
pFirstName
||
""
;
case
"
l+
"
:
return
pLastName
.
toLowerCase
()
||
""
;
case
"
L+
"
:
return
pLastName
||
""
;
case
"
f
"
:
return
pFirstName
.
charAt
(
firstNameIndex
++
).
toLowerCase
()
||
""
;
case
"
F
"
:
return
pFirstName
.
charAt
(
firstNameIndex
++
).
toUpperCase
()
||
""
;
case
"
l
"
:
return
pLastName
.
charAt
(
lastNameIndex
++
).
toLowerCase
()
||
""
;
case
"
L
"
:
return
pLastName
.
charAt
(
lastNameIndex
++
).
toUpperCase
()
||
""
;
}
});
return
userName
;
}
/**
* checks if an employee is used somewhere
*
* @param {String} pContactId the contact id of the user
*
* @return {boolean} if the employee has relations
*/
EmployeeUtils
.
hasRelations
=
function
(
pContactId
)
{
//sql queries with selects on tables where an employee can be used
var
queries
=
[
SqlCondition
.
begin
()
.
andPrepare
(
"
ACTIVITY.CREATOR
"
,
pContactId
)
.
buildSql
(
"
select 1 from ACTIVITY
"
),
SqlCondition
.
begin
()
.
andPrepare
(
"
TASK.REQUESTOR_CONTACT_ID
"
,
pContactId
)
.
buildSql
(
"
select 1 from TASK
"
),
SqlCondition
.
begin
()
.
andPrepare
(
"
TIMETRACKING.CONTACT_ID
"
,
pContactId
)
.
buildSql
(
"
select 1 from TIMETRACKING
"
)
];
return
queries
.
some
(
function
(
sql
)
{
return
db
.
cell
(
sql
)
!=
""
;
});
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment