works on items selection
This commit is contained in:
356
main.js
356
main.js
@@ -5302,9 +5302,9 @@ var $author$project$Main$Model = F5(
|
||||
return {groupLoot: groupLoot, loot: loot, merchantItems: merchantItems, player: player, state: state};
|
||||
});
|
||||
var $author$project$Main$PlayerChest = {$: 'PlayerChest'};
|
||||
var $author$project$Main$State = F4(
|
||||
function (navKey, route, error, menuOpen) {
|
||||
return {error: error, menuOpen: menuOpen, navKey: navKey, route: route};
|
||||
var $author$project$Main$State = F5(
|
||||
function (navKey, route, error, menuOpen, selectedItems) {
|
||||
return {error: error, menuOpen: menuOpen, navKey: navKey, route: route, selectedItems: selectedItems};
|
||||
});
|
||||
var $author$project$Main$Player = F4(
|
||||
function (id, name, debt, wealth) {
|
||||
@@ -5321,9 +5321,11 @@ var $author$project$Main$blankPlayer = A4(
|
||||
0,
|
||||
A4($author$project$Main$Wealth, 0, 0, 0, 0));
|
||||
var $elm$core$Platform$Cmd$batch = _Platform_batch;
|
||||
var $author$project$Main$GotLoot = function (a) {
|
||||
return {$: 'GotLoot', a: a};
|
||||
};
|
||||
var $author$project$Main$GotLoot = F2(
|
||||
function (a, b) {
|
||||
return {$: 'GotLoot', a: a, b: b};
|
||||
});
|
||||
var $author$project$Main$OfGroup = {$: 'OfGroup'};
|
||||
var $elm$json$Json$Decode$decodeString = _Json_runOnString;
|
||||
var $elm$http$Http$BadStatus_ = F2(
|
||||
function (a, b) {
|
||||
@@ -6130,12 +6132,30 @@ var $author$project$Main$lootDecoder = $elm$json$Json$Decode$list($author$projec
|
||||
var $author$project$Main$valueDecoder = function (thenDecoder) {
|
||||
return A2($elm$json$Json$Decode$field, 'value', thenDecoder);
|
||||
};
|
||||
var $author$project$Main$fetchGroupLoot = $elm$http$Http$get(
|
||||
{
|
||||
expect: A2(
|
||||
$elm$http$Http$expectJson,
|
||||
$author$project$Main$GotLoot($author$project$Main$OfGroup),
|
||||
$author$project$Main$valueDecoder($author$project$Main$lootDecoder)),
|
||||
url: 'http://localhost:8088/api/players/0/loot'
|
||||
});
|
||||
var $author$project$Main$OfShop = {$: 'OfShop'};
|
||||
var $author$project$Main$fetchShopInventory = $elm$http$Http$get(
|
||||
{
|
||||
expect: A2(
|
||||
$elm$http$Http$expectJson,
|
||||
$author$project$Main$GotLoot($author$project$Main$OfShop),
|
||||
$author$project$Main$valueDecoder($author$project$Main$lootDecoder)),
|
||||
url: 'http://localhost:8088/api/items'
|
||||
});
|
||||
var $author$project$Main$OfPlayer = {$: 'OfPlayer'};
|
||||
var $author$project$Main$fetchLoot = function (id) {
|
||||
return $elm$http$Http$get(
|
||||
{
|
||||
expect: A2(
|
||||
$elm$http$Http$expectJson,
|
||||
$author$project$Main$GotLoot,
|
||||
$author$project$Main$GotLoot($author$project$Main$OfPlayer),
|
||||
$author$project$Main$valueDecoder($author$project$Main$lootDecoder)),
|
||||
url: 'http://localhost:8088/api/players/' + ($elm$core$String$fromInt(id) + '/loot')
|
||||
});
|
||||
@@ -6176,6 +6196,15 @@ var $author$project$Main$initPlayer = function (id) {
|
||||
$author$project$Main$fetchLoot(id)
|
||||
]));
|
||||
};
|
||||
var $author$project$Main$fetchInitialData = function (playerId) {
|
||||
return $elm$core$Platform$Cmd$batch(
|
||||
_List_fromArray(
|
||||
[
|
||||
$author$project$Main$initPlayer(playerId),
|
||||
$author$project$Main$fetchShopInventory,
|
||||
$author$project$Main$fetchGroupLoot
|
||||
]));
|
||||
};
|
||||
var $elm$url$Url$Parser$State = F5(
|
||||
function (visited, unvisited, params, frag, value) {
|
||||
return {frag: frag, params: params, unvisited: unvisited, value: value, visited: visited};
|
||||
@@ -6423,12 +6452,12 @@ var $author$project$Main$init = F3(
|
||||
return _Utils_Tuple2(
|
||||
A5(
|
||||
$author$project$Main$Model,
|
||||
A4($author$project$Main$State, key, route, '', false),
|
||||
A5($author$project$Main$State, key, route, '', false, _List_Nil),
|
||||
$author$project$Main$blankPlayer,
|
||||
$elm$core$Maybe$Nothing,
|
||||
$elm$core$Maybe$Nothing,
|
||||
$elm$core$Maybe$Nothing),
|
||||
$author$project$Main$initPlayer(0));
|
||||
$author$project$Main$fetchInitialData(0));
|
||||
});
|
||||
var $elm$core$Platform$Sub$batch = _Platform_batch;
|
||||
var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil);
|
||||
@@ -6455,6 +6484,30 @@ var $author$project$Main$setError = F2(
|
||||
{error: error})
|
||||
});
|
||||
});
|
||||
var $elm$core$Basics$not = _Basics_not;
|
||||
var $author$project$Main$switchBooleanAt = function (idx) {
|
||||
return F2(
|
||||
function (i, value) {
|
||||
return _Utils_eq(i, idx) ? (!value) : value;
|
||||
});
|
||||
};
|
||||
var $author$project$Main$switchSelectionState = F2(
|
||||
function (idx, model) {
|
||||
var state = model.state;
|
||||
var selection = model.state.selectedItems;
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
state: _Utils_update(
|
||||
state,
|
||||
{
|
||||
selectedItems: A2(
|
||||
$elm$core$List$indexedMap,
|
||||
$author$project$Main$switchBooleanAt(idx),
|
||||
selection)
|
||||
})
|
||||
});
|
||||
});
|
||||
var $elm$url$Url$addPort = F2(
|
||||
function (maybePort, starter) {
|
||||
if (maybePort.$ === 'Nothing') {
|
||||
@@ -6499,6 +6552,15 @@ var $elm$url$Url$toString = function (url) {
|
||||
_Utils_ap(http, url.host)),
|
||||
url.path)));
|
||||
};
|
||||
var $elm$core$Maybe$withDefault = F2(
|
||||
function (_default, maybe) {
|
||||
if (maybe.$ === 'Just') {
|
||||
var value = maybe.a;
|
||||
return value;
|
||||
} else {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
var $author$project$Main$update = F2(
|
||||
function (msg, model) {
|
||||
switch (msg.$) {
|
||||
@@ -6531,7 +6593,36 @@ var $author$project$Main$update = F2(
|
||||
{
|
||||
state: _Utils_update(
|
||||
state,
|
||||
{route: page})
|
||||
{
|
||||
route: page,
|
||||
selectedItems: function () {
|
||||
switch (page.$) {
|
||||
case 'GroupLoot':
|
||||
return A2(
|
||||
$elm$core$List$map,
|
||||
function (v) {
|
||||
return false;
|
||||
},
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.groupLoot));
|
||||
case 'PlayerChest':
|
||||
return A2(
|
||||
$elm$core$List$map,
|
||||
function (v) {
|
||||
return false;
|
||||
},
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.loot));
|
||||
case 'Merchant':
|
||||
return A2(
|
||||
$elm$core$List$map,
|
||||
function (v) {
|
||||
return false;
|
||||
},
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.merchantItems));
|
||||
default:
|
||||
return _List_Nil;
|
||||
}
|
||||
}()
|
||||
})
|
||||
});
|
||||
}(),
|
||||
function () {
|
||||
@@ -6572,16 +6663,34 @@ var $author$project$Main$update = F2(
|
||||
model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
default:
|
||||
var result = msg.a;
|
||||
case 'GotLoot':
|
||||
var dest = msg.a;
|
||||
var result = msg.b;
|
||||
if (result.$ === 'Ok') {
|
||||
var loot = result.a;
|
||||
return _Utils_Tuple2(
|
||||
_Utils_update(
|
||||
model,
|
||||
{
|
||||
loot: $elm$core$Maybe$Just(loot)
|
||||
}),
|
||||
function () {
|
||||
switch (dest.$) {
|
||||
case 'OfPlayer':
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
loot: $elm$core$Maybe$Just(loot)
|
||||
});
|
||||
case 'OfGroup':
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
groupLoot: $elm$core$Maybe$Just(loot)
|
||||
});
|
||||
default:
|
||||
return _Utils_update(
|
||||
model,
|
||||
{
|
||||
merchantItems: $elm$core$Maybe$Just(loot)
|
||||
});
|
||||
}
|
||||
}(),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
} else {
|
||||
var error = result.a;
|
||||
@@ -6592,6 +6701,11 @@ var $author$project$Main$update = F2(
|
||||
model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
default:
|
||||
var idx = msg.a;
|
||||
return _Utils_Tuple2(
|
||||
A2($author$project$Main$switchSelectionState, idx, model),
|
||||
$elm$core$Platform$Cmd$none);
|
||||
}
|
||||
});
|
||||
var $elm$html$Html$article = _VirtualDom_node('article');
|
||||
@@ -6714,6 +6828,17 @@ var $author$project$Main$viewDebugSection = function (model) {
|
||||
[
|
||||
$elm$html$Html$text(
|
||||
'Route : ' + $elm$core$Debug$toString(model.state.route))
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$p,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('panel-block')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(
|
||||
'Selection : ' + $elm$core$Debug$toString(model.state.selectedItems))
|
||||
]))
|
||||
]));
|
||||
};
|
||||
@@ -6738,7 +6863,7 @@ var $author$project$Main$viewHeaderBar = function (model) {
|
||||
$elm$html$Html$nav,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('navbar'),
|
||||
$elm$html$Html$Attributes$class('navbar container'),
|
||||
$elm$html$Html$Attributes$class('is-info')
|
||||
]),
|
||||
_List_fromArray(
|
||||
@@ -6838,37 +6963,152 @@ var $author$project$Main$viewHeaderBar = function (model) {
|
||||
]));
|
||||
};
|
||||
var $elm$html$Html$table = _VirtualDom_node('table');
|
||||
var $elm$html$Html$th = _VirtualDom_node('th');
|
||||
var $elm$html$Html$thead = _VirtualDom_node('thead');
|
||||
var $author$project$Main$LootViewItemSwitched = function (a) {
|
||||
return {$: 'LootViewItemSwitched', a: a};
|
||||
};
|
||||
var $elm$core$List$filter = F2(
|
||||
function (isGood, list) {
|
||||
return A3(
|
||||
$elm$core$List$foldr,
|
||||
F2(
|
||||
function (x, xs) {
|
||||
return isGood(x) ? A2($elm$core$List$cons, x, xs) : xs;
|
||||
}),
|
||||
_List_Nil,
|
||||
list);
|
||||
});
|
||||
var $elm$core$Tuple$second = function (_v0) {
|
||||
var y = _v0.b;
|
||||
return y;
|
||||
};
|
||||
var $elm$html$Html$Attributes$classList = function (classes) {
|
||||
return $elm$html$Html$Attributes$class(
|
||||
A2(
|
||||
$elm$core$String$join,
|
||||
' ',
|
||||
A2(
|
||||
$elm$core$List$map,
|
||||
$elm$core$Tuple$first,
|
||||
A2($elm$core$List$filter, $elm$core$Tuple$second, classes))));
|
||||
};
|
||||
var $elm$html$Html$input = _VirtualDom_node('input');
|
||||
var $elm$html$Html$label = _VirtualDom_node('label');
|
||||
var $elm$html$Html$td = _VirtualDom_node('td');
|
||||
var $elm$html$Html$tr = _VirtualDom_node('tr');
|
||||
var $author$project$Main$viewItemTableRow = function (item) {
|
||||
return A2(
|
||||
$elm$html$Html$tr,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('table')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$td,
|
||||
_List_Nil,
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$p,
|
||||
_List_Nil,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(item.name)
|
||||
]))
|
||||
]))
|
||||
]));
|
||||
};
|
||||
var $elm$html$Html$Attributes$type_ = $elm$html$Html$Attributes$stringProperty('type');
|
||||
var $author$project$Main$viewItemTableRow = F3(
|
||||
function (selected, idx, item) {
|
||||
return A2(
|
||||
$elm$html$Html$tr,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$classList(
|
||||
_List_fromArray(
|
||||
[
|
||||
_Utils_Tuple2('is-selected', selected)
|
||||
]))
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$td,
|
||||
_List_Nil,
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$label,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('level checkbox'),
|
||||
$elm$html$Html$Events$onClick(
|
||||
$author$project$Main$LootViewItemSwitched(idx))
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('level-left')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$p,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('level-item')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(item.name)
|
||||
]))
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$div,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('level-right')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$p,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('level-item')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text(
|
||||
$elm$core$String$fromInt(item.base_price) + 'po')
|
||||
])),
|
||||
A2(
|
||||
$elm$html$Html$input,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('checkbox level-item'),
|
||||
$elm$html$Html$Attributes$type_('checkbox')
|
||||
]),
|
||||
_List_Nil)
|
||||
]))
|
||||
]))
|
||||
]))
|
||||
]));
|
||||
});
|
||||
var $author$project$Main$viewLoot = function (items) {
|
||||
return A2(
|
||||
$elm$html$Html$table,
|
||||
_List_Nil,
|
||||
A2($elm$core$List$map, $author$project$Main$viewItemTableRow, items));
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('table is-fullwidth is-striped')
|
||||
]),
|
||||
_Utils_ap(
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$thead,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('table-header')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$th,
|
||||
_List_Nil,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text('Nom')
|
||||
]))
|
||||
]))
|
||||
]),
|
||||
A2(
|
||||
$elm$core$List$indexedMap,
|
||||
$author$project$Main$viewItemTableRow(false),
|
||||
items)));
|
||||
};
|
||||
var $elm$html$Html$i = _VirtualDom_node('i');
|
||||
var $author$project$Main$showWealthField = F2(
|
||||
@@ -6981,7 +7221,7 @@ var $author$project$Main$viewPlayerBar = F2(
|
||||
$elm$html$Html$section,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('level is-mobile box')
|
||||
$elm$html$Html$Attributes$class('level container is-mobile box')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
@@ -7054,15 +7294,13 @@ var $author$project$Main$viewPlayerBar = F2(
|
||||
A2($author$project$Main$viewPlayerAction, player, route))
|
||||
]));
|
||||
});
|
||||
var $elm$core$Maybe$withDefault = F2(
|
||||
function (_default, maybe) {
|
||||
if (maybe.$ === 'Just') {
|
||||
var value = maybe.a;
|
||||
return value;
|
||||
} else {
|
||||
return _default;
|
||||
}
|
||||
});
|
||||
var $author$project$Main$viewSearchBar = A2(
|
||||
$elm$html$Html$input,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('input')
|
||||
]),
|
||||
_List_Nil);
|
||||
var $author$project$Main$view = function (model) {
|
||||
return {
|
||||
body: _List_fromArray(
|
||||
@@ -7083,11 +7321,15 @@ var $author$project$Main$view = function (model) {
|
||||
[
|
||||
A2(
|
||||
$elm$html$Html$p,
|
||||
_List_Nil,
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$Attributes$class('heading')
|
||||
]),
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text('Mon Coffre')
|
||||
])),
|
||||
$author$project$Main$viewSearchBar,
|
||||
$author$project$Main$viewLoot(
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.loot))
|
||||
]);
|
||||
@@ -7113,7 +7355,9 @@ var $author$project$Main$view = function (model) {
|
||||
_List_fromArray(
|
||||
[
|
||||
$elm$html$Html$text('Acheter des objets')
|
||||
]))
|
||||
])),
|
||||
$author$project$Main$viewLoot(
|
||||
A2($elm$core$Maybe$withDefault, _List_Nil, model.merchantItems))
|
||||
]);
|
||||
default:
|
||||
return _List_fromArray(
|
||||
|
||||
Reference in New Issue
Block a user