Skip to content

Commit d13c58e

Browse files
author
mreishman
committed
watchlist move actions work
1 parent b887aaa commit d13c58e

File tree

4 files changed

+107
-51
lines changed

4 files changed

+107
-51
lines changed

core/js/watchlist.js

Lines changed: 75 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,33 @@ function generateTrueFalseSelect(value)
5757
return returnText;
5858
}
5959

60+
function moveRowUp(currentRow)
61+
{
62+
let currentRowDiffOne = currentRow - 1;
63+
let currentRowItem = moveBlock(currentRowDiffOne, currentRow);
64+
let moved = moveBlock(currentRow, currentRowDiffOne);
65+
document.getElementById("rowNumber" + currentRowDiffOne).outerHTML = moved;
66+
document.getElementById("rowNumber" + currentRow).outerHTML = currentRowItem;
67+
}
68+
69+
function moveRowDown(currentRow)
70+
{
71+
let currentRowDiffOne = currentRow + 1;
72+
let currentRowItem = moveBlock(currentRowDiffOne, currentRow);
73+
let moved = moveBlock(currentRow, currentRowDiffOne);
74+
document.getElementById("rowNumber" + currentRowDiffOne).outerHTML = moved;
75+
document.getElementById("rowNumber" + currentRow).outerHTML = currentRowItem;
76+
}
77+
78+
function hideLastMoveDownButton()
79+
{
80+
for(let i = 1; i < countOfWatchList; i++)
81+
{
82+
document.getElementById("moveDown"+i).style.display = "block";
83+
}
84+
document.getElementById("moveDown"+countOfWatchList).style.display = "none";
85+
}
86+
6087
function addRowFunction()
6188
{
6289
countOfWatchList++;
@@ -86,11 +113,13 @@ function addRowFunction()
86113
item = item.replace(replaceString, "");
87114
}
88115
}
89-
locationInsert = "newRowLocationForWatchList"+countOfClicks;
90-
item += "<div style=\"display: inline-block;\" id=\""+locationInsert+"\"></div>";
116+
let newlocationInsert = "newRowLocationForWatchList"+countOfClicks;
117+
item += "<div style=\"display: inline-block;\" id=\""+newlocationInsert+"\"></div>";
91118
document.getElementById(locationInsert).outerHTML += item;
119+
locationInsert = newlocationInsert;
92120
document.getElementById('numberOfRows').value = countOfWatchList;
93121
countOfAddedFiles++;
122+
hideLastMoveDownButton();
94123
}
95124

96125
function deleteRowFunction(currentRow, decreaseCountWatchListNum)
@@ -101,58 +130,61 @@ function deleteRowFunction(currentRow, decreaseCountWatchListNum)
101130
{
102131
return;
103132
}
104-
newValue = document.getElementById('numberOfRows').value;
105-
if(currentRow < newValue)
133+
if(currentRow < countOfWatchList)
106134
{
107135
//this wasn't the last folder deleted, update others
108-
updateLaterFolders(currentRow, newValue);
136+
updateLaterFolders(currentRow, countOfWatchList);
109137
}
110-
newValue--;
138+
countOfWatchList--;
111139
if(countOfAddedFiles > 0)
112140
{
113141
countOfAddedFiles--;
114-
countOfWatchList--;
115142
}
116-
document.getElementById('numberOfRows').value = newValue;
143+
document.getElementById('numberOfRows').value = countOfWatchList;
144+
hideLastMoveDownButton();
117145
}
118146

119147
function updateLaterFolders(currentRow, newValue)
120148
{
121149
for(var i = currentRow + 1; i <= newValue; i++)
122150
{
123-
var updateItoIMinusOne = i - 1;
124-
var elementToUpdate = "rowNumber" + i;
125-
let item = $("#hiddenWatchlistFormBlank").html();
126-
item = item.replace(/{{i}}/g, updateItoIMinusOne);
127-
let watchListKeyIdFind = "watchListKey"+i;
128-
let previousElementNumIdentifierForKey = document.getElementsByName(watchListKeyIdFind)[0].value;
129-
item = item.replace(/{{key}}/g, previousElementNumIdentifierForKey);
130-
for(var j = 0; j < numberOfSubRows; j++)
151+
let item = moveBlock(i, i - 1);
152+
document.getElementById("rowNumber" + i).outerHTML = item;
153+
}
154+
}
155+
156+
function moveBlock(to, from)
157+
{
158+
let item = $("#hiddenWatchlistFormBlank").html();
159+
item = item.replace(/{{i}}/g, from);
160+
let watchListKeyIdFind = "watchListKey"+to;
161+
let previousElementNumIdentifierForKey = document.getElementsByName(watchListKeyIdFind)[0].value;
162+
item = item.replace(/{{key}}/g, previousElementNumIdentifierForKey);
163+
for(var j = 0; j < numberOfSubRows; j++)
164+
{
165+
let watchListItemIdFind = "watchListItem"+to+"-"+(j+1);
166+
let previousElementNumIdentifierForItem = document.getElementsByName(watchListItemIdFind)[0].value;
167+
let find = "{{"+from+"-"+(j+1)+"}}";
168+
let replaceString = new RegExp(find, 'g');
169+
170+
if(arrayOfKeysNonEnc[j] === "type")
171+
{
172+
item = item.replace(replaceString, generateTypeSelect(previousElementNumIdentifierForItem));
173+
}
174+
else if(arrayOfKeysNonEnc[j] === "gitType")
131175
{
132-
let watchListItemIdFind = "watchListItem"+i+"-"+(j+1);
133-
let previousElementNumIdentifierForItem = document.getElementsByName(watchListItemIdFind)[0].value;
134-
let find = "{{"+updateItoIMinusOne+"-"+(j+1)+"}}";
135-
let replaceString = new RegExp(find, 'g');
136-
137-
if(arrayOfKeysNonEnc[j] === "type")
138-
{
139-
item = item.replace(replaceString, generateTypeSelect(previousElementNumIdentifierForItem));
140-
}
141-
else if(arrayOfKeysNonEnc[j] === "gitType")
142-
{
143-
item = item.replace(replaceString, generateGitTypeSelect(previousElementNumIdentifierForItem));
144-
}
145-
else if(arrayOfKeysNonEnc[j] === "Archive")
146-
{
147-
item = item.replace(replaceString, generateTrueFalseSelect(previousElementNumIdentifierForItem));
148-
}
149-
else
150-
{
151-
item = item.replace(replaceString, previousElementNumIdentifierForItem);
152-
}
176+
item = item.replace(replaceString, generateGitTypeSelect(previousElementNumIdentifierForItem));
177+
}
178+
else if(arrayOfKeysNonEnc[j] === "Archive")
179+
{
180+
item = item.replace(replaceString, generateTrueFalseSelect(previousElementNumIdentifierForItem));
181+
}
182+
else
183+
{
184+
item = item.replace(replaceString, previousElementNumIdentifierForItem);
153185
}
154-
document.getElementById(elementToUpdate).outerHTML = item;
155186
}
187+
return item;
156188
}
157189

158190
function testConnection(currentRowInformation)
@@ -215,4 +247,8 @@ function checkWebsiteStatus(sendUrlHere)
215247
document.getElementById("connectionCheckStatusRed").style.display = "inline-block";
216248
}
217249
});
218-
}
250+
}
251+
252+
$( document ).ready(function() {
253+
hideLastMoveDownButton();
254+
});

core/php/functions/watchlistFunctions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,20 @@ function generateWatchlistBlock($defaultArray, $arrayKeys, $key = "{{key}}", $it
137137
<table width=\"100%\">
138138
<tr>
139139
<th width=\"50%\" style=\" text-align: center;\">
140-
<a style=\"display: block;\" class=\"mainLinkClass\" onclick=\"deleteRowFunction(" . $i . ", true);\">Remove</a>
140+
<a class=\"mainLinkClass watchlistButton\" onclick=\"deleteRowFunction(" . $i . ", true);\">Remove</a>
141141
</th>
142142
<th width=\"50%\" style=\" text-align: center;\">
143-
<a style=\"display: block;\" class=\"mainLinkClass\" onclick=\"testConnection(dataForWatchFolder" . $i . ");\" >Check Connection</a>
143+
<a class=\"mainLinkClass watchlistButton\" onclick=\"testConnection(dataForWatchFolder" . $i . ");\" >Check Connection</a>
144144
</th>
145145
</tr>
146146
</table>
147147
<table width=\"100%\">
148148
<tr>
149149
<th width=\"50%\" style=\" text-align: center;\">
150-
<a style=\"display: block;\" class=\"mainLinkClass\" > Move Up One </a>
150+
<a id=\"moveUp".$i."\" onclick=\"moveRowUp(".$i.")\" class=\"mainLinkClass watchlistButton\" > Move Up One </a>
151151
</th>
152152
<th width=\"50%\" style=\" text-align: center;\">
153-
<a style=\"display: block;\" class=\"mainLinkClass\" > Move Down One </a>
153+
<a id=\"moveDown".$i."\" onclick=\"moveRowDown(".$i.")\" class=\"mainLinkClass watchlistButton\" > Move Down One </a>
154154
</th>
155155
</tr>
156156
</table>

core/template/theme.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ body{
33
margin: 0;
44
}
55

6+
.watchlistButton
7+
{
8+
display: block;
9+
}
10+
11+
#moveUp1
12+
{
13+
display: none;
14+
}
15+
616
.meterCommit
717
{
818
height: 5px;
@@ -202,7 +212,7 @@ body{
202212
position: fixed;
203213
top: 40px;
204214
left: 100px;
205-
overflow: -moz-scrollbars-vertical;
215+
overflow: -moz-scrollbars-vertical;
206216
overflow-y: scroll;
207217
}
208218
.menuBarLeft{
@@ -358,15 +368,15 @@ body{
358368
background-color: rgb(235, 235, 235);
359369
font-size: 16px;
360370
height: 30px;
361-
display: none;
371+
display: none;
362372
position: absolute;
363373
left: 120px;
364374
top: 0;
365375
padding-top: 10px;
366376
padding-right: 8px;
367377
padding-left: 8px;
368378
}
369-
.back-to-top:hover {
379+
.back-to-top:hover {
370380
background-color: rgba(135, 135, 135, 1);
371381
}
372382
.colorSelectorDiv
@@ -450,7 +460,7 @@ body{
450460
border: 1px solid black;
451461
padding-top: 5px;
452462
padding-bottom: 5px;
453-
padding-left: 5px;
463+
padding-left: 5px;
454464
}
455465

456466

local/default/template/theme.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ body{
33
margin: 0;
44
}
55

6+
.watchlistButton
7+
{
8+
display: block;
9+
}
10+
11+
#moveUp1
12+
{
13+
display: none;
14+
}
15+
616
.meterCommit
717
{
818
height: 5px;
@@ -203,7 +213,7 @@ body{
203213
position: fixed;
204214
top: 40px;
205215
left: 100px;
206-
overflow: -moz-scrollbars-vertical;
216+
overflow: -moz-scrollbars-vertical;
207217
overflow-y: scroll;
208218
}
209219
.menuBarLeft{
@@ -359,15 +369,15 @@ body{
359369
background-color: rgb(235, 235, 235);
360370
font-size: 16px;
361371
height: 30px;
362-
display: none;
372+
display: none;
363373
position: absolute;
364374
left: 120px;
365375
top: 0;
366376
padding-top: 10px;
367377
padding-right: 8px;
368378
padding-left: 8px;
369379
}
370-
.back-to-top:hover {
380+
.back-to-top:hover {
371381
background-color: rgba(135, 135, 135, 1);
372382
}
373383
.colorSelectorDiv
@@ -451,7 +461,7 @@ body{
451461
border: 1px solid black;
452462
padding-top: 5px;
453463
padding-bottom: 5px;
454-
padding-left: 5px;
464+
padding-left: 5px;
455465
}
456466

457467

0 commit comments

Comments
 (0)