|
@@ -1,33 +1,60 @@
|
1
|
|
-var dataSelect = "";
|
2
|
|
-
|
3
|
1
|
function checkPromoId(promoid)
|
4
|
2
|
{
|
5
|
3
|
return promoid.match(/A[1-5]/) != null;
|
6
|
4
|
}
|
7
|
5
|
|
8
|
|
-if($("title").text() === "Documents") {
|
9
|
|
- dataSelect = $("option")[0].value;
|
10
|
|
-}
|
11
|
|
-
|
12
|
|
-$(document).on('change', 'select', function(e) {
|
13
|
|
- if($("title").text() === "Documents") {
|
14
|
|
- dataSelect = this.options[e.target.selectedIndex].value;
|
15
|
|
- }
|
16
|
|
-});
|
17
|
|
-
|
18
|
|
-$('.fa-pencil').on("click", function() {
|
|
6
|
+function editRow() {
|
19
|
7
|
var row = $(this).parent().parent();
|
20
|
8
|
var rang = $(row.children()[0]);
|
|
9
|
+ var promo = $(row.children()[1]);
|
21
|
10
|
var rangValeur = rang.html();
|
|
11
|
+ var promoValeur = $(promo[0]).attr("class");
|
|
12
|
+ var promos = $("#promo").children();
|
|
13
|
+ var str = '<select class="tempPromos">';
|
|
14
|
+ var selected = "";
|
|
15
|
+
|
22
|
16
|
rang.html('<input type="number" value="'+rangValeur+'" size="2" style="width:35px" />');
|
|
17
|
+ $(promo[0]).removeClass(promoValeur);
|
|
18
|
+ for(var i = 0; i < promos.length; i++)
|
|
19
|
+ {
|
|
20
|
+ if (promos[i].value === promoValeur)
|
|
21
|
+ {
|
|
22
|
+ selected = "selected";
|
|
23
|
+ }
|
|
24
|
+ else
|
|
25
|
+ {
|
|
26
|
+ selected = "";
|
|
27
|
+ }
|
|
28
|
+ str += '<option value="'+promos[i].value+'" '+selected+'>'+promos[i].text+'</option>';
|
|
29
|
+ }
|
|
30
|
+ str += "</select>";
|
|
31
|
+ promo.html(str);
|
23
|
32
|
$(this).addClass("fa-check");
|
24
|
33
|
$(this).removeClass("fa-pencil");
|
25
|
34
|
$(this).off("click");
|
26
|
35
|
$(this).on("click", function () {
|
27
|
|
- rangValeur = $(rang.children()[0]).value;
|
|
36
|
+ rangValeur = $(rang.children()[0]).val();
|
28
|
37
|
rang.html(rangValeur);
|
|
38
|
+ promoValeur = promo.children().val();
|
|
39
|
+ promo.addClass(promoValeur);
|
|
40
|
+ var promoName = "";
|
|
41
|
+ for(var i = 0; i < promos.length; i++)
|
|
42
|
+ {
|
|
43
|
+ if (promos[i].value === promoValeur)
|
|
44
|
+ {
|
|
45
|
+ promoName = promos[i].text;
|
|
46
|
+ }
|
|
47
|
+ }
|
|
48
|
+ promo.html(promoName);
|
|
49
|
+ $(this).addClass("fa-pencil");
|
|
50
|
+ $(this).removeClass("fa-check");
|
|
51
|
+ // Insert AJAX request here
|
|
52
|
+ $(this).off("click");
|
|
53
|
+ $(this).on("click", editRow);
|
29
|
54
|
});
|
30
|
|
-});
|
|
55
|
+}
|
|
56
|
+
|
|
57
|
+$('.fa-pencil').on("click", editRow);
|
31
|
58
|
|
32
|
59
|
$('#addForm').submit(function(e) {
|
33
|
60
|
e.preventDefault();
|
|
@@ -37,7 +64,7 @@ $('#addForm').submit(function(e) {
|
37
|
64
|
{
|
38
|
65
|
case "Documents":
|
39
|
66
|
data.append("document", $("#file")[0].files[0]);
|
40
|
|
- data.append("promo", dataSelect);
|
|
67
|
+ data.append("promo", $("#promo").val());
|
41
|
68
|
data.append("rang", $("#rang").val());
|
42
|
69
|
data.append("libelle", $("#libelle").val());
|
43
|
70
|
|