Commit 662c8d7b authored by Sudhir Kumar's avatar Sudhir Kumar

delete api is done, need to make this an array

parent f5f6efec
...@@ -42,9 +42,15 @@ type State = ...@@ -42,9 +42,15 @@ type State =
{ documents :: DocumentsView { documents :: DocumentsView
, deleteRows :: Boolean , deleteRows :: Boolean
, deleteRowId :: Array Int , deleteRowId :: Array Int
, delete :: Array DeleteRow
} }
newtype DeleteRow = DeleteRow
{
deleteRowId :: Int
, deleteRows :: Boolean
}
data Action data Action
= SendFavorites Int = SendFavorites Int
...@@ -60,10 +66,10 @@ performAction (SendFavorites nid) {path : nodeId} _ = void $ do ...@@ -60,10 +66,10 @@ performAction (SendFavorites nid) {path : nodeId} _ = void $ do
_ <- liftEffect $ log err _ <- liftEffect $ log err
modifyState identity modifyState identity
Right d -> modifyState identity Right d -> modifyState identity
--TODO add array of delete rows here
performAction (DeleteDocuments nid) _ _ = void $ do performAction (DeleteDocuments nid) _ s = void $ do
_ <- liftEffect $ log $ show nid _ <- liftEffect $ log $ show nid
modifyState \state -> state {deleteRowId = ( cons nid []), deleteRows = true} modifyState \state -> state {deleteRowId = ( cons nid s.deleteRowId), deleteRows = true}
performAction Trash {path:nodeId} state = void $ do performAction Trash {path:nodeId} state = void $ do
s' <- lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents : state.deleteRowId}) s' <- lift $ deleteDocuments nodeId (DeleteDocumentQuery {documents : state.deleteRowId})
...@@ -73,6 +79,9 @@ performAction Trash {path:nodeId} state = void $ do ...@@ -73,6 +79,9 @@ performAction Trash {path:nodeId} state = void $ do
modifyState identity modifyState identity
Right d -> modifyState identity Right d -> modifyState identity
-- modifyState \state -> state {deleteRowId = ( cons nid s.deleteRowId), deleteRows = true} for referrence
newtype DocumentsView newtype DocumentsView
= DocumentsView = DocumentsView
...@@ -83,6 +92,7 @@ newtype DocumentsView ...@@ -83,6 +92,7 @@ newtype DocumentsView
, source :: String , source :: String
, fav :: Boolean , fav :: Boolean
, ngramCount :: Int , ngramCount :: Int
, delete :: Boolean
} }
...@@ -208,9 +218,18 @@ layoutDocview = simpleSpec performAction render ...@@ -208,9 +218,18 @@ layoutDocview = simpleSpec performAction render
[ a [className $ fa r.fav <> "fa-star" ,onClick $ (\_-> dispatch $ (SendFavorites r._id))] [] [ a [className $ fa r.fav <> "fa-star" ,onClick $ (\_-> dispatch $ (SendFavorites r._id))] []
] ]
-- TODO show date: Year-Month-Day only -- TODO show date: Year-Month-Day only
, text r.date , if (r.delete) then
, a [ href (toUrl Front Url_Document r._id) ] [ text r.title ] div [ style {textDecoration : "line-through"}][text r.date]
, text r.source else
div [ ][text r.date]
, if (r.delete) then
a [ href (toUrl Front Url_Document r._id), style {textDecoration : "line-through"} ] [ text r.title ]
else
a [ href (toUrl Front Url_Document r._id) ] [ text r.title ]
, if (r.delete) then
div [style {textDecoration : "line-through"}] [ text r.source]
else
div [] [ text r.source]
, input [ _type "checkbox", onClick $ (\_ -> dispatch $ (DeleteDocuments r._id))] , input [ _type "checkbox", onClick $ (\_ -> dispatch $ (DeleteDocuments r._id))]
] ]
, delete: true , delete: true
...@@ -242,6 +261,7 @@ loadPage {nodeId, limit, offset, orderBy} = do ...@@ -242,6 +261,7 @@ loadPage {nodeId, limit, offset, orderBy} = do
, source : (\(Hyperdata hr) -> hr.source) r.hyperdata , source : (\(Hyperdata hr) -> hr.source) r.hyperdata
, fav : r.favorite , fav : r.favorite
, ngramCount : r.ngramCount , ngramCount : r.ngramCount
, delete : false
} }
convOrderBy (T.ASC (T.ColumnName "Date")) = DateAsc convOrderBy (T.ASC (T.ColumnName "Date")) = DateAsc
convOrderBy (T.DESC (T.ColumnName "Date")) = DateDesc convOrderBy (T.DESC (T.ColumnName "Date")) = DateDesc
...@@ -253,11 +273,11 @@ loadPage {nodeId, limit, offset, orderBy} = do ...@@ -253,11 +273,11 @@ loadPage {nodeId, limit, offset, orderBy} = do
--------------------------------------------------------- ---------------------------------------------------------
sampleData' :: DocumentsView sampleData' :: DocumentsView
sampleData' = DocumentsView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1} sampleData' = DocumentsView {_id : 1, url : "", date : "date3", title : "title", source : "source", fav : false, ngramCount : 1, delete : false}
sampleData :: Array DocumentsView sampleData :: Array DocumentsView
--sampleData = replicate 10 sampleData' --sampleData = replicate 10 sampleData'
sampleData = map (\(Tuple t s) -> DocumentsView {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10}) sampleDocuments sampleData = map (\(Tuple t s) -> DocumentsView {_id : 1, url : "", date : "2017", title: t, source: s, fav : false, ngramCount : 10, delete : false}) sampleDocuments
sampleDocuments :: Array (Tuple String String) sampleDocuments :: Array (Tuple String String)
sampleDocuments = [Tuple "Macroscopic dynamics of the fusion process" "Journal de Physique Lettres",Tuple "Effects of static and cyclic fatigue at high temperature upon reaction bonded silicon nitride" "Journal de Physique Colloques",Tuple "Reliability of metal/glass-ceramic junctions made by solid state bonding" "Journal de Physique Colloques",Tuple "High temperature mechanical properties and intergranular structure of sialons" "Journal de Physique Colloques",Tuple "SOLUTIONS OF THE LANDAU-VLASOV EQUATION IN NUCLEAR PHYSICS" "Journal de Physique Colloques",Tuple "A STUDY ON THE FUSION REACTION 139La + 12C AT 50 MeV/u WITH THE VUU EQUATION" "Journal de Physique Colloques",Tuple "Atomic structure of \"vitreous\" interfacial films in sialon" "Journal de Physique Colloques",Tuple "MICROSTRUCTURAL AND ANALYTICAL CHARACTERIZATION OF Al2O3/Al-Mg COMPOSITE INTERFACES" "Journal de Physique Colloques",Tuple "Development of oxidation resistant high temperature NbTiAl alloys and intermetallics" "Journal de Physique IV Colloque",Tuple "Determination of brazed joint constitutive law by inverse method" "Journal de Physique IV Colloque",Tuple "Two dimensional estimates from ocean SAR images" "Nonlinear Processes in Geophysics",Tuple "Comparison Between New Carbon Nanostructures Produced by Plasma with Industrial Carbon Black Grades" "Journal de Physique III",Tuple "<i>Letter to the Editor:</i> SCIPION, a new flexible ionospheric sounder in Senegal" "Annales Geophysicae",Tuple "Is reducibility in nuclear multifragmentation related to thermal scaling?" "Physics Letters B",Tuple "Independence of fragment charge distributions of the size of heavy multifragmenting sources" "Physics Letters B",Tuple "Hard photons and neutral pions as probes of hot and dense nuclear matter" "Nuclear Physics A",Tuple "Surveying the nuclear caloric curve" "Physics Letters B",Tuple "A hot expanding source in 50 A MeV Xe+Sn central reactions" "Physics Letters B"] sampleDocuments = [Tuple "Macroscopic dynamics of the fusion process" "Journal de Physique Lettres",Tuple "Effects of static and cyclic fatigue at high temperature upon reaction bonded silicon nitride" "Journal de Physique Colloques",Tuple "Reliability of metal/glass-ceramic junctions made by solid state bonding" "Journal de Physique Colloques",Tuple "High temperature mechanical properties and intergranular structure of sialons" "Journal de Physique Colloques",Tuple "SOLUTIONS OF THE LANDAU-VLASOV EQUATION IN NUCLEAR PHYSICS" "Journal de Physique Colloques",Tuple "A STUDY ON THE FUSION REACTION 139La + 12C AT 50 MeV/u WITH THE VUU EQUATION" "Journal de Physique Colloques",Tuple "Atomic structure of \"vitreous\" interfacial films in sialon" "Journal de Physique Colloques",Tuple "MICROSTRUCTURAL AND ANALYTICAL CHARACTERIZATION OF Al2O3/Al-Mg COMPOSITE INTERFACES" "Journal de Physique Colloques",Tuple "Development of oxidation resistant high temperature NbTiAl alloys and intermetallics" "Journal de Physique IV Colloque",Tuple "Determination of brazed joint constitutive law by inverse method" "Journal de Physique IV Colloque",Tuple "Two dimensional estimates from ocean SAR images" "Nonlinear Processes in Geophysics",Tuple "Comparison Between New Carbon Nanostructures Produced by Plasma with Industrial Carbon Black Grades" "Journal de Physique III",Tuple "<i>Letter to the Editor:</i> SCIPION, a new flexible ionospheric sounder in Senegal" "Annales Geophysicae",Tuple "Is reducibility in nuclear multifragmentation related to thermal scaling?" "Physics Letters B",Tuple "Independence of fragment charge distributions of the size of heavy multifragmenting sources" "Physics Letters B",Tuple "Hard photons and neutral pions as probes of hot and dense nuclear matter" "Nuclear Physics A",Tuple "Surveying the nuclear caloric curve" "Physics Letters B",Tuple "A hot expanding source in 50 A MeV Xe+Sn central reactions" "Physics Letters B"]
......
...@@ -19,6 +19,7 @@ initialState = ...@@ -19,6 +19,7 @@ initialState =
{ documents : D.sampleData' { documents : D.sampleData'
, deleteRows : false , deleteRows : false
, deleteRowId : [] , deleteRowId : []
, delete : []
} }
, ngramsView : {} -- N.initialState , ngramsView : {} -- N.initialState
, activeTab : 0 , activeTab : 0
......
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