add share update, albeit a bit ugly. also add device to share
[mTask.git] / Shares / mTaskShare.icl
index 8c0ae61..ed4b5e3 100644 (file)
@@ -12,7 +12,20 @@ derive class iTask MTaskShareType, MTaskShare
 
 manageShares :: [MTaskShare] -> Task ()
 manageShares shares = withShared Nothing $ \cs->forever $
-       viewSharesGrid cs shares /*||- (viewSharedInformation "" [] cs*/ @! ()//)//||- editCurrentShare cs
+       (viewSharesGrid cs shares -|| updateShares shares <<@ ArrangeVertical) 
+       @! ()
+updateShares :: [MTaskShare] -> Task BCValue
+updateShares shares = anyTask (map updateS shares) <<@ ArrangeWithTabs
+
+updateS :: MTaskShare -> Task BCValue
+updateS sh = flip (<<@) (Title $ toString sh.identifier) $ forever $
+               viewSharedInformation "Current value" [] (getSDSShare sh)
+       ||- (
+                       updateSharedInformation "New value" [] (getSDSShare sh)
+               >>= \nv->allTasks (map (sendMessages [MTUpd sh.identifier nv]) sh.withDevice)
+               >>| treturn nv
+               )
+       <<@ ArrangeHorizontal
 
 //     >&^ \st->whileUnchanged st $ \msh->case msh of
 //             Nothing = viewShares shares
@@ -54,10 +67,11 @@ viewShare m = viewSharedInformation "" [] (getSDSShare m)
 getSDSShare :: MTaskShare -> Shared BCValue
 getSDSShare s=:{realShare=(MTaskWithShare id),value} = memoryShare id value
 
-makeShare :: String Int BCValue -> Task MTaskShare
-makeShare withTask identifier value = treturn 
+makeShare :: String MTaskDevice Int BCValue -> Task MTaskShare
+makeShare withTask withDevice identifier value = treturn 
                {MTaskShare
                |withTask=[withTask]
+               ,withDevice=[withDevice]
                ,identifier=identifier
                ,value=value
                ,realShare=MTaskWithShare $ "mTaskSDS-" +++ toString identifier