AJAX reordered list back to yesod. THIS TOOK 3 HOURS. Aargh
This commit is contained in:
parent
e0e01ee671
commit
6af91dadb8
4 changed files with 19 additions and 25 deletions
|
@ -63,30 +63,22 @@ data Actions
|
||||||
{ setupRepoLink :: Route WebApp }
|
{ setupRepoLink :: Route WebApp }
|
||||||
| SyncingRepoActions
|
| SyncingRepoActions
|
||||||
{ setupRepoLink :: Route WebApp
|
{ setupRepoLink :: Route WebApp
|
||||||
, moveUpRepoList :: Route WebApp
|
|
||||||
, moveDownRepoList :: Route WebApp
|
|
||||||
, syncToggleLink :: Route WebApp
|
, syncToggleLink :: Route WebApp
|
||||||
}
|
}
|
||||||
| NotSyncingRepoActions
|
| NotSyncingRepoActions
|
||||||
{ setupRepoLink :: Route WebApp
|
{ setupRepoLink :: Route WebApp
|
||||||
, moveUpRepoList :: Route WebApp
|
|
||||||
, moveDownRepoList :: Route WebApp
|
|
||||||
, syncToggleLink :: Route WebApp
|
, syncToggleLink :: Route WebApp
|
||||||
}
|
}
|
||||||
|
|
||||||
mkSyncingRepoActions :: UUID -> Actions
|
mkSyncingRepoActions :: UUID -> Actions
|
||||||
mkSyncingRepoActions u = SyncingRepoActions
|
mkSyncingRepoActions u = SyncingRepoActions
|
||||||
{ setupRepoLink = EditRepositoryR u
|
{ setupRepoLink = EditRepositoryR u
|
||||||
, moveUpRepoList = MoveRepositoryUp u
|
|
||||||
, moveDownRepoList = MoveRepositoryDown u
|
|
||||||
, syncToggleLink = DisableSyncR u
|
, syncToggleLink = DisableSyncR u
|
||||||
}
|
}
|
||||||
|
|
||||||
mkNotSyncingRepoActions :: UUID -> Actions
|
mkNotSyncingRepoActions :: UUID -> Actions
|
||||||
mkNotSyncingRepoActions u = NotSyncingRepoActions
|
mkNotSyncingRepoActions u = NotSyncingRepoActions
|
||||||
{ setupRepoLink = EditRepositoryR u
|
{ setupRepoLink = EditRepositoryR u
|
||||||
, moveUpRepoList = MoveRepositoryUp u
|
|
||||||
, moveDownRepoList = MoveRepositoryDown u
|
|
||||||
, syncToggleLink = EnableSyncR u
|
, syncToggleLink = EnableSyncR u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +87,7 @@ needsEnabled (DisabledRepoActions _) = True
|
||||||
needsEnabled _ = False
|
needsEnabled _ = False
|
||||||
|
|
||||||
notSyncing :: Actions -> Bool
|
notSyncing :: Actions -> Bool
|
||||||
notSyncing (SyncingRepoActions _ _ _ _) = False
|
notSyncing (SyncingRepoActions _ _) = False
|
||||||
notSyncing _ = True
|
notSyncing _ = True
|
||||||
|
|
||||||
{- Called by client to get a list of repos, that refreshes
|
{- Called by client to get a list of repos, that refreshes
|
||||||
|
@ -124,7 +116,8 @@ repoListDisplay reposelector = do
|
||||||
where
|
where
|
||||||
ident = "repolist"
|
ident = "repolist"
|
||||||
|
|
||||||
type RepoList = [(String, String, Actions)]
|
-- (num, name, (uuid, actions))
|
||||||
|
type RepoList = [(String, String, (UUID, Actions))]
|
||||||
|
|
||||||
{- A numbered list of known repositories,
|
{- A numbered list of known repositories,
|
||||||
- with actions that can be taken on them. -}
|
- with actions that can be taken on them. -}
|
||||||
|
@ -186,7 +179,7 @@ repoList reposelector
|
||||||
zip3
|
zip3
|
||||||
<$> pure counter
|
<$> pure counter
|
||||||
<*> Remote.prettyListUUIDs (map fst l')
|
<*> Remote.prettyListUUIDs (map fst l')
|
||||||
<*> pure (map snd l')
|
<*> pure l'
|
||||||
counter = map show ([1..] :: [Int])
|
counter = map show ([1..] :: [Int])
|
||||||
|
|
||||||
getEnableSyncR :: UUID -> Handler ()
|
getEnableSyncR :: UUID -> Handler ()
|
||||||
|
@ -201,15 +194,11 @@ flipSync enable uuid = do
|
||||||
changeSyncable mremote enable
|
changeSyncable mremote enable
|
||||||
redirect RepositoriesR
|
redirect RepositoriesR
|
||||||
|
|
||||||
getMoveRepositoryUp :: UUID -> Handler ()
|
getRepositoriesReorderR :: Handler ()
|
||||||
getMoveRepositoryUp u = do
|
getRepositoriesReorderR = do
|
||||||
reorderRepository u
|
moved <- runInputGet $ ireq textField "moved"
|
||||||
redirect RepositoriesR
|
list <- lookupGetParams "list[]"
|
||||||
|
error $ show (moved, list)
|
||||||
getMoveRepositoryDown :: UUID -> Handler ()
|
|
||||||
getMoveRepositoryDown u = do
|
|
||||||
reorderRepository u
|
|
||||||
redirect RepositoriesR
|
|
||||||
|
|
||||||
reorderRepository :: UUID -> Handler ()
|
reorderRepository :: UUID -> Handler ()
|
||||||
reorderRepository uuid = do
|
reorderRepository uuid = do
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/ DashboardR GET HEAD
|
/ DashboardR GET HEAD
|
||||||
|
|
||||||
/repositories RepositoriesR GET
|
/repositories RepositoriesR GET
|
||||||
/repositories/moveup/#UUID MoveRepositoryUp GET
|
/repositories/reorder RepositoriesReorderR GET
|
||||||
/repositories/movedown/#UUID MoveRepositoryDown GET
|
|
||||||
|
|
||||||
/noscript NoScriptR GET
|
/noscript NoScriptR GET
|
||||||
/noscript/auto NoScriptAutoR GET
|
/noscript/auto NoScriptAutoR GET
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
Repositories
|
Repositories
|
||||||
<table .table .table-condensed>
|
<table .table .table-condensed>
|
||||||
<tbody #costsortable>
|
<tbody #costsortable>
|
||||||
$forall (_num, name, actions) <- repolist
|
$forall (num, name, (uuid, actions)) <- repolist
|
||||||
<tr .repoline>
|
<tr .repoline ##{"costsortable_" ++ fromUUID uuid}>
|
||||||
<td .handle>
|
<td .handle>
|
||||||
<i .icon-resize-vertical></i>
|
<i .icon-resize-vertical></i>
|
||||||
#{name}
|
#{name}
|
||||||
|
|
|
@ -8,8 +8,14 @@ $(function() {
|
||||||
},
|
},
|
||||||
stop: function(event, ui) {
|
stop: function(event, ui) {
|
||||||
ui.item.children(".draghide").show();
|
ui.item.children(".draghide").show();
|
||||||
|
var list = $("#costsortable").sortable("toArray");
|
||||||
|
var moved = ui.item.attr("id");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
'url': "http://localhost/testajax",
|
'url': "@{RepositoriesReorderR}",
|
||||||
|
'data': {
|
||||||
|
'moved': moved,
|
||||||
|
'list': list
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue