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
3fa094ea
Commit
3fa094ea
authored
4 years ago
by
Pascal Neub
Browse files
Options
Downloads
Patches
Plain Diff
[Projekt: xRM-Sales][TicketNr.: 1062845][Angebot/Beleg: Verschieben von Angebotsposten/Belegposten]
parent
a86b56b3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Item_lib/process.js
+32
-2
32 additions, 2 deletions
process/Item_lib/process.js
with
32 additions
and
2 deletions
process/Item_lib/process.js
+
32
−
2
View file @
3fa094ea
...
...
@@ -4,7 +4,8 @@ import("system.db");
import
(
"
system.neon
"
);
/**
* a static Utility class for the items like OfferItem and OrderItem.
* A Utility class for the items like OfferItem and OrderItem.
* Loads all items and stores them as trees
*
* @class
*/
...
...
@@ -26,10 +27,12 @@ function MoveableItemUtils(pTargetTable, pItemIdField, pItemSortField, pItemPosF
{
var
uid
=
data
[
i
][
0
];
var
pos
=
data
[
i
][
2
];
var
trimmedPos
=
pos
.
replace
(
/
(
^|
\.)\d
*$/
,
""
)
var
trimmedPos
=
pos
.
replace
(
/
(
^|
\.)\d
*$/
,
""
)
;
if
(
!
this
.
posMap
.
has
(
pos
))
{
this
.
posMap
.
set
(
pos
,
{
childs
:
[]});
}
var
curr
=
this
.
posMap
.
get
(
pos
);
curr
.
uid
=
uid
;
...
...
@@ -37,13 +40,18 @@ function MoveableItemUtils(pTargetTable, pItemIdField, pItemSortField, pItemPosF
curr
.
parent
=
trimmedPos
;
if
(
!
this
.
posMap
.
has
(
trimmedPos
))
{
this
.
posMap
.
set
(
trimmedPos
,
{
childs
:
[]});
}
this
.
posMap
.
get
(
trimmedPos
).
childs
.
push
(
pos
);
this
.
uidToPos
.
set
(
uid
,
pos
);
}
}
/**
* Checks weather the item can move up
*/
MoveableItemUtils
.
prototype
.
canMoveUp
=
function
(
pItemId
)
{
var
pos
=
this
.
uidToPos
.
get
(
pItemId
);
...
...
@@ -52,6 +60,9 @@ MoveableItemUtils.prototype.canMoveUp = function(pItemId)
return
parentChilds
.
indexOf
(
pos
)
>=
1
;
}
/**
* Checks weather the item can move down
*/
MoveableItemUtils
.
prototype
.
canMoveDown
=
function
(
pItemId
)
{
var
pos
=
this
.
uidToPos
.
get
(
pItemId
);
...
...
@@ -60,10 +71,15 @@ MoveableItemUtils.prototype.canMoveDown = function(pItemId)
return
parentChilds
.
indexOf
(
pos
)
<
parentChilds
.
length
-
1
;
}
/**
* Moves the item up
*/
MoveableItemUtils
.
prototype
.
moveUp
=
function
(
pItemId
)
{
if
(
!
this
.
canMoveUp
(
pItemId
))
{
throw
new
Error
(
"
Item can't be moved up
"
);
}
var
pos
=
this
.
uidToPos
.
get
(
pItemId
);
var
item
=
this
.
posMap
.
get
(
pos
);
...
...
@@ -82,10 +98,15 @@ MoveableItemUtils.prototype.moveUp = function(pItemId)
neon
.
refreshAll
();
}
/**
* Moves the item down
*/
MoveableItemUtils
.
prototype
.
moveDown
=
function
(
pItemId
)
{
if
(
!
this
.
canMoveDown
(
pItemId
))
{
throw
new
Error
(
"
Item can't be moved down
"
);
}
var
pos
=
this
.
uidToPos
.
get
(
pItemId
);
var
item
=
this
.
posMap
.
get
(
pos
);
...
...
@@ -104,6 +125,9 @@ MoveableItemUtils.prototype.moveDown = function(pItemId)
neon
.
refreshAll
();
}
/**
* Swaps item positions
*/
MoveableItemUtils
.
prototype
.
moveItem
=
function
(
pTargetStmts
,
pId
,
pPos
)
{
var
pos
=
this
.
uidToPos
.
get
(
pId
);
...
...
@@ -122,6 +146,9 @@ MoveableItemUtils.prototype.moveItem = function(pTargetStmts, pId, pPos)
}
}
/**
* Updates the sorting
*/
MoveableItemUtils
.
prototype
.
updateSorting
=
function
()
{
var
stmts
=
[];
...
...
@@ -144,6 +171,9 @@ MoveableItemUtils.prototype.updateSorting = function()
db
.
updates
(
stmts
);
}
/**
* Returns the item data via sql
*/
MoveableItemUtils
.
prototype
.
getData
=
function
()
{
return
newSelect
([
this
.
itemIdField
,
this
.
itemSortField
,
this
.
itemPosField
])
...
...
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