Commit e355309b authored by Bas Lijnse's avatar Bas Lijnse

Merge branch '308-make-use-of-active-tab-information' into 'master'

Resolve "Make use of active tab information"

Closes #308

See merge request !355
parents 13ed3303 98b9f662
Pipeline #35777 passed with stage
in 6 minutes and 55 seconds
......@@ -654,3 +654,7 @@
flex: 0 0 25%;
align-self: stretch;
}
.itasks-hidden {
display: none;
}
......@@ -143,11 +143,11 @@ where
]
= (Ok (uia type attr, (mbVal, attr)), vst)
onEdit _ (_, mbVal) (_, attrs) vst = (Ok (NoChange, (mbVal`, attrs)), vst)
onEdit _ (_, mbVal) (_, attrs) vst = (Ok (ChangeUI [SetAttribute "value" valJSON] [], (mbVal`, attrs)), vst)
where
mbVal` = case mbVal of
Just val | isValid attrs val = Just val
_ = Nothing
(mbVal`, valJSON) = case mbVal of
Just val | isValid attrs val = (Just val, toJSON val)
_ = (Nothing, JSONNull)
onRefresh toJSON dp new (mbOld, attrs) vst
| mbOld === Just new = (Ok (NoChange, (mbOld, attrs)), vst)
......
......@@ -14,6 +14,9 @@ from Data.Set import instance Foldable Set
from Data.Tuple import appSnd
from Data.Map import instance Functor (Map k)
from Data.Foldable import maximum
from Control.Monad import class Monad(..), >>=
from Control.Applicative import class Applicative(..), class pure(pure)
from Data.Maybe import instance Monad Maybe
import Text.GenJSON
......@@ -556,15 +559,18 @@ nodeSelected_ ruleNo (SelectByDepth n) p _ moves = length p == n
nodeSelected_ ruleNo (SelectDescendents) [_:_] _ moves = True
nodeSelected_ ruleNo (SelectDescendents) _ _ moves = False
nodeSelected_ ruleNo (SelectByType t) _ lui moves = fromMaybe False
(fmap (\n -> nodeType_ ruleNo n === t) (selectNode_ ruleNo True fst (lui,moves)))
$ selectNode_ ruleNo True fst (lui,moves)
>>= \node -> return $ nodeType_ ruleNo node === t
nodeSelected_ ruleNo (SelectByHasAttribute k) _ lui moves = fromMaybe False
(fmap (\n -> isJust ('DM'.get k (nodeAttributes_ ruleNo n))) (selectNode_ ruleNo True fst (lui,moves)))
$ selectNode_ ruleNo True fst (lui,moves)
>>= \node -> 'DM'.get k (nodeAttributes_ ruleNo node)
>>= \_ -> return True
nodeSelected_ ruleNo (SelectByAttribute k p) _ lui moves = fromMaybe False
(fmap (\n -> maybe False p ('DM'.get k (nodeAttributes_ ruleNo n))) (selectNode_ ruleNo True fst (lui,moves)))
nodeSelected_ ruleNo (SelectByClass c) _ lui moves = fromMaybe False
(fmap (\n -> maybe False (hasClass c) ('DM'.get "class" (nodeAttributes_ ruleNo n))) (selectNode_ ruleNo True fst (lui,moves)))
$ selectNode_ ruleNo True fst (lui,moves)
>>= \node -> 'DM'.get k (nodeAttributes_ ruleNo node)
>>= \value -> return (p value)
nodeSelected_ ruleNo (SelectByClass c) path lui moves
= nodeSelected_ ruleNo (SelectByAttribute "class" (hasClass c)) path lui moves
where
hasClass name (JSONArray items) = isMember name [item \\ JSONString item <- items]
hasClass _ _ = False
......
......@@ -231,7 +231,7 @@ itasks.Component = {
me.beforeChildRemove(idx,child);
if(me.initialized && child.domEl) {
me.containerEl.removeChild(me.containerEl.childNodes[idx]);
me.containerEl.removeChild(child.domEl);
}
me.children.splice(idx,1);
me.afterChildRemove(idx);
......@@ -280,13 +280,12 @@ itasks.Component = {
var me = this;
me.attributes[name] = value;
me.onAttributeChange(name,value);
me._onAttributeChange(name,value);
},
onAttributeChange: function(name,value) {
_onAttributeChange: function(name,value) {
var me = this;
if(name == 'class') {
me.domEl.className = '';
me.domEl.className = me.cssPrefix + me.cssCls;
if(Array.isArray(value)) {
value.forEach(function(cls) {
me.domEl.classList.add(cls);
......@@ -294,8 +293,11 @@ itasks.Component = {
} else {
me.domEl.classList.add(value);
}
} else {
me.onAttributeChange(name,value);
}
},
onAttributeChange: function(name,value) {},
onUIChange: function(change) {
var me = this;
me.world=me.world.then (function(){
......
......@@ -4,6 +4,7 @@ definition module iTasks.WF.Combinators.Common
*/
import iTasks.SDS.Definition
import iTasks.WF.Combinators.Core
from iTasks.WF.Tasks.Interaction import :: ChoiceOption
from StdBool import not
from Data.Map import :: Map
......@@ -321,6 +322,10 @@ whileUnchangedWith :: !(r r -> Bool) !(sds () r w) (r -> Task b) -> Task b | iTa
*/
withSelection :: (Task c) (a -> Task b) (sds () (Maybe a) ()) -> Task b | iTask a & iTask b & iTask c & RWShared sds
/**
*/
workOnChosenTask :: !(((String, Int) -> String) -> ChoiceOption (String, Int)) ![(String, Task a)] -> Task a | iTask a
/**
* Append a task to the set of top level tasks
*
......
......@@ -5,6 +5,8 @@ implementation module iTasks.WF.Combinators.Common
import StdEnv
import Data.Functor
import Data.Func
import Data.Map.GenJSON
import qualified Data.Map as DM
import iTasks.Engine
import iTasks.Internal.SDS
......@@ -236,6 +238,36 @@ whileUnchangedWith eq share task
withSelection :: (Task c) (a -> Task b) (sds () (Maybe a) ()) -> Task b | iTask a & iTask b & iTask c & RWShared sds
withSelection def tfun s = whileUnchanged s (maybe (def @? const NoValue) tfun)
workOnChosenTask :: !(((String, Int) -> String) -> ChoiceOption (String, Int)) ![(String, Task a)] -> Task a | iTask a
workOnChosenTask choiceOption options =
updateChoiceAs [choiceOption fst] [(label,n) \\ (label,_) <- options & n <- [1..]] snd 1 >&> \choiceIdx ->
( parallel
[(Embedded, managementTask choiceIdx): [(Embedded, \_ -> task) \\ (_, task) <- options]]
[]
<<@ ApplyLayout
( layoutSubUIs
( SelectAND
(SelectByDepth 1)
(SelectByAttribute "visible" $ \val -> val =: (JSONBool False))
)
(addCSSClass "itasks-hidden")
)
)
-&&-
(watch choiceIdx <<@ ApplyLayout hideUI)
@? \taskValue ->
case taskValue of
Value (values, Just choiceIdx) _ -> snd $ values !! choiceIdx
_ -> NoValue
where
managementTask choiceIdx taskList = whileUnchanged choiceIdx updateVisible
where
updateVisible choice = upd (setVisible choice) (sdsFocus fullTaskListFilter taskList) @? const NoValue
setVisible choice (_,items) =
[(taskId,'DM'.put "visible" (JSONBool (Just idx == choice)) managementAttributes)
\\ {TaskListItem|taskId,managementAttributes} <- items & idx <- [0..]
]
appendTopLevelTask :: !TaskAttributes !Bool !(Task a) -> Task TaskId | iTask a
appendTopLevelTask attr evalDirect task = get applicationOptions
>>- \eo->appendTask (Detached evalDirect attr) (\_->mtune eo task @! ()) topLevelTasks
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment