Compare commits

...

269 Commits

Author SHA1 Message Date
Alexander D. Bondoc 0cb656a60a
Merge pull request #138 from lexintegritastech/fix-ux-for-clickable-links 4 years ago
Alexander D. Bondoc 5b61cf9dba
Remove `is_citator_tab` params 4 years ago
Alexander D. Bondoc 6b4830b22a
Merge pull request #137 from lexintegritastech/fix-ux-for-clickable-links 4 years ago
Alexander D. Bondoc 0e00dd3f0c
Fix `link` in `citator#tab` 4 years ago
Alexander D. Bondoc 63755e8268
Merge pull request #136 from lexintegritastech/fix-ux-for-clickable-links 4 years ago
Alexander D. Bondoc 08480eab46
Fix UX for clickable links 4 years ago
Angel Aviel Domaoan d05d7fa28a Add auto deployment branches 4 years ago
Angel Aviel Domaoan 412c8b58aa Add restart mode for `load_balancer` 4 years ago
Alexander D. Bondoc 0cf7193f13
Merge pull request #135 from lexintegritastech/minor-updates 4 years ago
Alexander D. Bondoc 9bebc0180b
Fix `css` for `footnotes` 4 years ago
Alexander D. Bondoc 2964d47de1
Fix font size for `doctrines#content` 4 years ago
Alexander D. Bondoc 05b0f0f94a
Fix `prompt` message 4 years ago
Alexander D. Bondoc 7aefbbb23f
Change `Editors Note` to `Editor's Note` 4 years ago
Alexander D. Bondoc 2805c86964
Merge pull request #134 from lexintegritastech/fix-sorting-for-documents-search 4 years ago
alexdbondoc17 ce34a3f4c2 Fix `sorting` in `documents#search` 4 years ago
Alexander D. Bondoc 37d6fd421a Merge pull request #133 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7c9b443dfc Enhance `selectize` for `doctrines#suggested_contents` 4 years ago
Alexander D. Bondoc e65c339289
Merge pull request #132 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9f06b3c0cd Fix linking of `document` 4 years ago
Alexander D. Bondoc 7ec5ad0bb9
Merge pull request #131 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 5ea09cf3ad Improve `grouping` for `doctrines#search` 4 years ago
Alexander D. Bondoc 83d340b013
Merge pull request #130 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 e66ea59b44 Fix `doctrines#destroy` 4 years ago
alexdbondoc17 6010d4e096 Fix UI for `doctrines#form` 4 years ago
Alexander D. Bondoc c7c72c5ee7
Merge pull request #129 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 8acbcbdae7 Add delay after saving `doctrines` 4 years ago
Alexander D. Bondoc 79636b0a90
Merge pull request #128 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 411896fc81 Enhance UI for `documents`, `doctrines`, and `annotations#form` 4 years ago
Alexander D. Bondoc c3bc942e19
Merge pull request #127 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ee2595e9d1 Fix `doctrines#edit` 4 years ago
Alexander D. Bondoc 9e1748d357
Merge pull request #126 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 66858ce260 Fix saving of `doctrines` 4 years ago
Alexander D. Bondoc 201674e543
Merge pull request #125 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ea8f1d61e0 Minor updates for `doctrines` and `annotations` 4 years ago
Alexander D. Bondoc 729073bbd6
Merge pull request #124 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9795dd8ca8 Improve UI for `doctrinines#search` 4 years ago
Alexander D. Bondoc 4a27beca8d
Merge pull request #123 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 81c27a3806 Enhance `doctrine#form` 4 years ago
Alexander D. Bondoc c9abc3411b
Merge pull request #122 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 353e53bb43 Fix `doctrine_search` 4 years ago
alexdbondoc17 185030b45d Use SOLR for `annotations` 4 years ago
alexdbondoc17 d92783bdfa Improve searchable in `doctrine` 4 years ago
alexdbondoc17 a446aa3bd5 Removee `searchable` in `doctrine_jurisprudence` 4 years ago
alexdbondoc17 74a094aae8 Add `callback` for `annotation` 4 years ago
Alexander D. Bondoc 28d4a20016
Merge pull request #121 from lexintegritastech/enhance-form-for-doctrines 4 years ago
alexdbondoc17 06de925d8b Fix issue in `doctrines#form` 4 years ago
Alexander D. Bondoc 45bec150ac
Merge pull request #120 from lexintegritastech/enhance-form-for-doctrines 4 years ago
alexdbondoc17 117981d2f5 Enhance `doctrines#form` 4 years ago
Alexander D. Bondoc 32311ab1b9
Merge pull request #119 from lexintegritastech/enhance-ui-for-analysis-tab-in-documents-show 4 years ago
alexdbondoc17 7d79f9d9f4 Enhance UI for `analysis ttab` in `documents#show` 4 years ago
Alexander D. Bondoc 8308ce3934
Merge pull request #118 from lexintegritastech/enhance-searchable-in-annotations 4 years ago
Alexander D. Bondoc 9e9c6c5ea5
Merge pull request #117 from lexintegritastech/enhance-ui-for-doctrines-modal-form 4 years ago
alexdbondoc17 f5e36b7437 Enhance UI for `doctrines#modal_form` 4 years ago
Alexander D. Bondoc 537fb356c5
Merge pull request #116 from lexintegritastech/feature-enhance-ui 4 years ago
alexdbondoc17 d0094c1345 Enhanc`searchable` in `annotations` 4 years ago
janpaulo 1549514e13
Fix selectize issue for all 4 years ago
Alexander D. Bondoc 104c0df415
Merge pull request #115 from lexintegritastech/fix-issue-in-application-layout 4 years ago
alexdbondoc17 01a040958e Fix issue in `application#layout` 4 years ago
Angel Aviel Domaoan cc5e703a8a
Merge pull request #113 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9c17ee115c Fix temporary sorting for `documents#doctrines` 4 years ago
Angel Aviel Domaoan 98d60dca96
Merge pull request #112 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 0e8da90449 Temporary fix for `sorting` of `doctrines` 4 years ago
alexdbondoc17 1c8bd06a3f Fix `document#date` 4 years ago
alexdbondoc17 58099bba41 Implement sanitation for `phil_rep` 4 years ago
Angel Aviel Domaoan 4920225246
Merge pull request #111 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo ba95906f5c
Fix scroll into a footnotes 4 years ago
janpaulo 1321cca174
Add succes and error message for annotation and doctrines 4 years ago
Alexander D. Bondoc 1fc6ec5694
Merge pull request #110 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7b4d5481ae Enhance UI for `doctrines` and `annotations` 4 years ago
alexdbondoc17 099854f3ad Add `content` in `annotation` 4 years ago
alexdbondoc17 f14998b01c Enhance `searchable` for `jurisprudence`, `doctrine`, and `annotation` 4 years ago
Alexander D. Bondoc 792d7f32c7
Merge pull request #109 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 3a8e1ce27a
Fix error for citation finder 4 years ago
Angel Aviel Domaoan 2894706a8a
Merge pull request #107 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo eaa5ab3d32
Change button for citation finder 4 years ago
Angel Aviel Domaoan 4da7152ec1 Implement new parser for doctrines 4 years ago
Alexander D. Bondoc 2be01091b2
Merge pull request #106 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ed3fd52c8f Add `form` validation for `doctrines#modal_form` 4 years ago
alexdbondoc17 4d5a9462ef Suggest `headnote` in `doctrine` modal `form` 4 years ago
Alexander D. Bondoc 2d89915690
Merge pull request #105 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 19c3b09136 Fix validation for `doctrine` 4 years ago
Alexander D. Bondoc ff0662d8bb
Merge pull request #104 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ba521d084d Make `root#index` the `documents#index` 4 years ago
Alexander D. Bondoc f52cb13ce6
Merge pull request #103 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3415a7658b Fix buttons spelling 4 years ago
Alexander D. Bondoc f393481673
Merge pull request #102 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 e6e30144b6 Fix `citation_finder` search for `case_lists` 4 years ago
Alexander D. Bondoc 85cb54a2c9
Merge pull request #101 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3744e9357c Fix bug for `annotations` 4 years ago
Alexander D. Bondoc 45f5a8d791
Merge pull request #100 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 4a3a8108a7 Sanitize `citation_finder` in `jurisprudence_search` 4 years ago
alexdbondoc17 aeb09ff360 Sanitize `citation_finder` in `document_search` 4 years ago
Alexander D. Bondoc 9a8ff8a3ba
Merge pull request #99 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ab06f59469 Revert changes for `searchable` in `document` 4 years ago
Alexander D. Bondoc 204097ca6f
Merge pull request #98 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7960921520 Fix `searchable` for `citation_finder` in `document` 4 years ago
alexdbondoc17 eeae268509 Add `order_by` in `annotations#search` 4 years ago
Alexander D. Bondoc ca804bc736
Merge pull request #97 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3f0e16feaa Fix `citation_finder#search` in `document` 4 years ago
Alexander D. Bondoc 9b4ac90af4
Merge pull request #96 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 bf755666ef Fix `sorting` of `annotation` 4 years ago
alexdbondoc17 f4657de4b9 Add `headnote` in `doctrines#index` component 4 years ago
alexdbondoc17 d5135f7f56 Fix cursor of `subjects` and `doctrines` 4 years ago
alexdbondoc17 1bc838ebed Change placeholder for `case lists` search 4 years ago
Alexander D. Bondoc e5e877a8f6
Merge pull request #95 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3318de9600 Fix refresh button in `document#advanced_search` component 4 years ago
Alexander D. Bondoc 5b88ce7262
Merge pull request #94 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3535030ed8 Fix `delete` of `annotations` 4 years ago
Alexander D. Bondoc 89501bd677
Merge pull request #93 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 84b3957ed6 Fix `morph` of `annotations` 4 years ago
Alexander D. Bondoc 115e7618f0
Merge pull request #92 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 8c8ea407f6 Add `margin-bottom` for `annotations` 4 years ago
Alexander D. Bondoc c775815f49
Merge pull request #91 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 b1fa34dfc2 Fix sorting of `documents` for `case lists` 4 years ago
alexdbondoc17 136a574e79 Fix `pagination` for `doctrines` 4 years ago
alexdbondoc17 3d2e135975 Add `citation_finder` in `case_lists#search` 4 years ago
Angel Aviel Domaoan 8c91ab3186 Configure mailer 4 years ago
Angel Aviel Domaoan 8566e12046 Implement okcomputer for healthchecks 4 years ago
Angel Aviel Domaoan 88d64da031 Require auth for sidekiq routes 4 years ago
alexdbondoc17 71d56cecf1 Fix issue for not displaying of new created doctrine 4 years ago
alexdbondoc17 1948e49392 Fix component for `doctrines#index` 4 years ago
alexdbondoc17 92548141ea Fix UI for `decisions` 4 years ago
alexdbondoc17 25d8a749df Fix back button for `document_doctrines#show` 4 years ago
alexdbondoc17 5f851449da Fix saving of `annotations` 4 years ago
alexdbondoc17 56e26e8344 Implement `documents#search` when clicking to `subjects` Offcanvas 4 years ago
Angel Aviel Domaoan cda8badb1e Fix years 4 years ago
Angel Aviel Domaoan b144e5a23d Fix docker_compose_up_services 4 years ago
Angel Aviel Domaoan dfe25ae762 Fix docker-compose 4 years ago
Angel Aviel Domaoan 777784b20c Fix years 4 years ago
Alexander D. Bondoc 23d8eeea4f
Merge pull request #88 from lexintegritastech/feature-enhance-ui 4 years ago
Angel Aviel Domaoan 33bc8f9a26 Fix years 4 years ago
Angel Aviel Domaoan 57b82ce4be Fix healthcheck for workers 4 years ago
janpaulo 99b8eb565d
Change position add button for sub levels 4 years ago
janpaulo cfa965670f
Add loading snipper per page 4 years ago
Angel Aviel Domaoan 041b7c590a Configure `docker_compose_up_services` for production and staging 4 years ago
janpaulo 6fcfa5af5f Set width table for document show search 4 years ago
Angel Aviel Domaoan 6f2c419131 Fix sort_by and years 4 years ago
Angel Aviel Domaoan 9fd378d494 Implement workers 4 years ago
Angel Aviel Domaoan 412887e56e Implement sunspot-queue 4 years ago
Angel Aviel Domaoan 86a9d99100 Implement rails credentials for multiple environments 4 years ago
Alexander D. Bondoc d6837c2b28
Merge pull request #86 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 77c9df64a1 Fix url for `Offcanvas` 4 years ago
Alexander D. Bondoc 28a8095e2f
Merge pull request #85 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo dc5503a1ed
Add back button in doctrine show 4 years ago
Alexander D. Bondoc a635b84f31
Merge pull request #84 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 e6ea4d4e6a Enhance UI for `subjects#offcanvas` and `doctrines#offcanvas` 4 years ago
Alexander D. Bondoc 7dbac7e518
Merge pull request #83 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9712f91703 Enhance custom `pagination` for `StimulusReflex` 4 years ago
alexdbondoc17 724e16c4c3 Fix search for `annotations` 4 years ago
Alexander D. Bondoc 4e00821e70
Merge pull request #82 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9b63b2293e Add Component for `doctrines#index` 4 years ago
alexdbondoc17 9179060672 Add back button to `subject_indexes#show` 4 years ago
Alexander D. Bondoc c0337a80ed
Merge pull request #81 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 cfa969a1e3 Fix UI for `case_lists_search_results` 4 years ago
Alexander D. Bondoc edd56c330f
Merge pull request #80 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7e2c68e3d6 Improve UI for `documents`, `doctrines`, and `annotations` 4 years ago
Angel Aviel Domaoan dffeb48443
Merge pull request #79 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 0e67315f7f
Full width document show for cited in 4 years ago
Angel Aviel Domaoan 4b65448ef3 Add restart mode for solr 4 years ago
Angel Aviel Domaoan b7f397490a Add redis to depends_on for web 4 years ago
Alexander D. Bondoc daa3679d45
Merge pull request #78 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 a66786c9df Fix bugs from `annotations` CRUD 4 years ago
Angel Aviel Domaoan 01403fa028
Merge pull request #77 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 6aff545626 Fix pagination for `cited_documents` 4 years ago
Angel Aviel Domaoan 49ed6d0588
Merge pull request #72 from lexintegritastech/feature-enhance-ui 4 years ago
Angel Aviel Domaoan fccc11fa61
Merge pull request #76 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 a0ee3f5c0b Fix UI for `documents#show` 4 years ago
Angel Aviel Domaoan 9135baa160
Merge pull request #75 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 0b7bb9ffa8 Remove ponente 4 years ago
Angel Aviel Domaoan 7f7adcff07 Remove syllabus 4 years ago
Alexander D. Bondoc a311289978
Merge pull request #73 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7a2732417c Fix `doctrine#show` bug 4 years ago
janpaulo 4e29407497
Enhance ui for subject index show 4 years ago
Alexander D. Bondoc 3c3fb7453f
Merge pull request #71 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7e19d84e84 Fix UI for `documents` 4 years ago
Alexander D. Bondoc d9eba8ebf8
Merge pull request #70 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 690c569793
Chnage ui for no document search 4 years ago
Alexander D. Bondoc 94b47a2ecf
Merge pull request #69 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 f1fa322c4f Improve `jurisprudence#search` 4 years ago
Alexander D. Bondoc dea6f7228f
Merge pull request #68 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 7da90b0d6f
Add fields for search 4 years ago
Alexander D. Bondoc 039e4e071b
Merge pull request #67 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 fa204a9afc Minor UI fixes 4 years ago
Alexander D. Bondoc 5c4e66691e
Merge pull request #66 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 0c54ce628e Fix issue for `subjects#form` 4 years ago
alexdbondoc17 a3eb6589be Fix `data-action` for `doctrines` offcanvas 4 years ago
Alexander D. Bondoc 44f2b67518
Merge pull request #65 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 25de4bcf25 Initial viewing updates 4 years ago
Alexander D. Bondoc 09db635fa6
Merge pull request #64 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 48c6b5ed6b
Add pagination in cited in 4 years ago
janpaulo 120580af94
Remove home in index home 4 years ago
janpaulo 1f32229d01
Change image for login 4 years ago
Alexander D. Bondoc a414efc842
Merge pull request #63 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 31baa776e1 Fix `doctrines#show` component 4 years ago
Alexander D. Bondoc d3b793fed3
Merge pull request #62 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 1243af9db9 Fix link for `doctrines` offcanvas 4 years ago
Alexander D. Bondoc a2717b88ca
Merge pull request #61 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 efab230381 Fix `offcanvas` for `doctrines` 4 years ago
Alexander D. Bondoc 58d6da775f
Merge pull request #59 from lexintegritastech/feature-enhance-ui 4 years ago
Alexander D. Bondoc 8c0ad7d874
Merge pull request #60 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 79f9b94ff7 Improve `footnote` 4 years ago
janpaulo f33b9c4ba7
Fix side button for doctine and subjects 4 years ago
Alexander D. Bondoc a09e8e63a4
Merge pull request #58 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 02f8d5cc4e Fix bug for `accordion` 4 years ago
Alexander D. Bondoc 1263afb8fa
Merge pull request #57 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo a152a12b5f
Fix breadcrumb link 4 years ago
Alexander D. Bondoc c8ae5d2c6c
Merge pull request #54 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 582733dac6
Fix indention in offcanvas 4 years ago
janpaulo 4c18bc1788
Fix collapsible accordion for parent 4 years ago
janpaulo 4058de54c3
Add side button in documrnt show 4 years ago
Alexander D. Bondoc cb0800860d
Merge pull request #56 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 d288c8298e Add `form-control` class for `created_at` 4 years ago
Alexander D. Bondoc 62a46f3053
Merge pull request #55 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 d90f3446fd Minor UI Updates 4 years ago
alexdbondoc17 c5b4bd5110 Add UI for `reports` 4 years ago
Angel Aviel Domaoan c5222a185a
Merge pull request #53 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo a87eae7b28
Fullwidth subject index table and doctrine 4 years ago
janpaulo 2e6da67d26
Enhance ui for subject index 4 years ago
janpaulo c9b765942f
Add side button for subjects and doctrine 4 years ago
Angel Aviel Domaoan 7b246a19d9 Update target server for deployment 4 years ago
Angel Aviel Domaoan 7db5197694 Setup Sentry for JS 4 years ago
Alexander D. Bondoc c901c71f90
Merge pull request #52 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 5e3664af47 Implement `subject_accordion_component` for `subject_indexes#index` 4 years ago
alexdbondoc17 359f084f77 Enhance background of buttons 4 years ago
alexdbondoc17 703b20b281 Fix `routing` for `doctrines` 4 years ago
alexdbondoc17 763add5169 Improve UI for `decisions` 4 years ago
Alexander D. Bondoc b693185d0e
Merge pull request #50 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 47ce931c1a
Final offcanvas subjects and doctirines 4 years ago
janpaulo 2963e1c088
initial setup for subject index offcnavas 4 years ago
Alexander D. Bondoc 3b1ad3cb83
Merge pull request #51 from lexintegritastech/Change-spelling 4 years ago
janpaulo 48616520ba
Change tab title for browser 4 years ago
janpaulo 9c0d08ef33
Fix wrong spelling for decisions 4 years ago
Alexander D. Bondoc d5c99ecd76
Merge pull request #49 from lexintegritastech/feature-enhancement-ui 4 years ago
alexdbondoc17 96c38e8335 Implement spinner for loading of `subjects` accordion 4 years ago
Alexander D. Bondoc 755367b975
Merge pull request #48 from lexintegritastech/feature-enhancement-ui 4 years ago
alexdbondoc17 63eab67ecc Improve `subejcts` accordion 4 years ago
Alexander D. Bondoc dc3294b1a7
Merge pull request #47 from lexintegritastech/feature-enhancement-ui 4 years ago
alexdbondoc17 5ccfafdc61 Fix stimulus for `subjects` accordion 4 years ago
Alexander D. Bondoc e0035895cb
Merge pull request #46 from lexintegritastech/feature-enhancement-ui 4 years ago
alexdbondoc17 f922e548c8 Improve offcanvas 4 years ago
Alexander D. Bondoc 9bc18af1a3
Merge pull request #45 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 51ec0610e1
Add css file for document search 4 years ago
Angel Aviel Domaoan 57f37a7fa7
Merge pull request #44 from lexintegritastech/feature-enhance-ui 4 years ago
Angel Aviel Domaoan 8ae1f2eff9
Merge pull request #43 from lexintegritastech/feature-enhancement-ui 4 years ago
janpaulo 30eacb2484
Relayout document views 4 years ago
janpaulo 806cb3d197
Enahnce ui for document advanced search 4 years ago
Angel Aviel Domaoan 14744a463f Implement CSV parser for doctrines 4 years ago
Angel Aviel Domaoan 2483548d33 Fix library_subjects in subjects 4 years ago
Angel Aviel Domaoan b449107f0a Fix migrations 4 years ago
Angel Aviel Domaoan f6538a1736 Fix CSV parser for subjects 4 years ago
alexdbondoc17 4e777a45a2 Implement `OffCanvas` for `Subject` 4 years ago
alexdbondoc17 9c4cf193ab Merge branch 'feature-enhancement-ui' of https://github.com/lexintegritastech/cdao-pjet into feature-enhancement-ui 4 years ago
janpaulo 69301237bc
Final navbar setup 4 years ago
alexdbondoc17 d0b73bd3c9
Add component for `document#search` 4 years ago
alexdbondoc17 0e86e0ffe3 Add component for `document#search` 4 years ago
janpaulo c4e7701ef1
Initial setup navBar 4 years ago
Angel Aviel Domaoan 0c47f0c29b
Merge pull request #42 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 1b91b80dc9 Fix UI for `sidenav` 4 years ago
Angel Aviel Domaoan a0010760c4
Merge pull request #41 from lexintegritastech/feature-enhancement-ui 4 years ago
Angel Aviel Domaoan d79f783687
Merge pull request #40 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3345aeb669 Update searching for `documents` 4 years ago
janpaulo acf73a15d0
Enhance ui for sessions 4 years ago
alexdbondoc17 d4456f337f Implement \`API\` request of CRUD in \`doctrines\` 4 years ago
Angel Aviel Domaoan 70a8e31523 Add headnote in doctrines 4 years ago
Angel Aviel Domaoan d384b6b0ad Implement CSV parser for subjects 4 years ago
alexdbondoc17 360f3d5a95 Enahncement of UI for `doctrines` 4 years ago
Angel Aviel Domaoan 44116d116c Remove document in doctrines 4 years ago
Angel Aviel Domaoan ffbff6dbf8 Remove test directory 4 years ago
Angel Aviel Domaoan 3069c8577e Implement DoctrineJurisprudence 4 years ago
  1. 1
      .dockerignore
  2. 2
      .github/workflows/deployment.yml
  3. 4
      .gitignore
  4. 1
      Procfile
  5. 1
      Procfile-worker
  6. 29
      README.md
  7. 4
      app/components/analysis_form_component/analysis_form_component.html.erb
  8. 51
      app/components/annotation_form_component.rb
  9. 51
      app/components/annotation_form_component/annotation_form_component.html.erb
  10. 6
      app/components/annotation_marks_modal_form_component.rb
  11. 19
      app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb
  12. 8
      app/components/citation_index_table_component.rb
  13. 7
      app/components/citation_index_table_component/citation_index_table_component.html.erb
  14. 10
      app/components/doctrine_form_component.rb
  15. 38
      app/components/doctrine_form_component/doctrine_form_component.html.erb
  16. 65
      app/components/doctrine_index_component.rb
  17. 58
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  18. 6
      app/components/doctrine_index_table_component.rb
  19. 10
      app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb
  20. 16
      app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb
  21. 39
      app/components/doctrines_offcanvas_accordion_component.rb
  22. 27
      app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb
  23. 11
      app/components/doctrines_offcanvas_component.rb
  24. 40
      app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb
  25. 13
      app/components/document_advanced_search_component.rb
  26. 36
      app/components/document_advanced_search_component/document_advanced_search_component.html.erb
  27. 35
      app/components/document_doctrine_index_component.rb
  28. 42
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  29. 43
      app/components/document_doctrine_show_component.rb
  30. 71
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  31. 5
      app/components/document_index_table_component/document_index_table_component.html.erb
  32. 2
      app/components/documents_years_component/documents_years_component.html.erb
  33. 25
      app/components/jurisprudences_index_table_component.rb
  34. 6
      app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb
  35. 8
      app/components/pagination_component.rb
  36. 15
      app/components/pagination_component/pagination_component.html.erb
  37. 47
      app/components/reports_search_results_component.rb
  38. 42
      app/components/reports_search_results_component/reports_search_results_component.html.erb
  39. 5
      app/components/sidenav_component.rb
  40. 43
      app/components/sidenav_component/sidenav_component.html.erb
  41. 8
      app/components/subject_accordion_component.rb
  42. 76
      app/components/subject_accordion_component/subject_accordion_component.html.erb
  43. 8
      app/components/subject_index_form_component.rb
  44. 17
      app/components/subject_index_form_component/subject_index_form_component.html.erb
  45. 38
      app/components/subjects_accordion_component.rb
  46. 31
      app/components/subjects_accordion_component/subjects_accordion_component.html.erb
  47. 39
      app/components/subjects_offcanvas_accordion_component.rb
  48. 27
      app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb
  49. 11
      app/components/subjects_offcanvas_component.rb
  50. 40
      app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb
  51. 93
      app/components/subjects_sidenav_sub_menu_component/subjects_sidenav_sub_menu_component.html.erb
  52. 48
      app/controllers/api/doctrine/annotations_controller.rb
  53. 63
      app/controllers/api/doctrines_controller.rb
  54. 7
      app/controllers/api/documents_controller.rb
  55. 40
      app/controllers/api/jurisprudence/doctrines_controller.rb
  56. 4
      app/controllers/api/jurisprudences_controller.rb
  57. 2
      app/controllers/api/subjects_controller.rb
  58. 21
      app/controllers/concerns/annotation_search.rb
  59. 33
      app/controllers/concerns/doctrine_search.rb
  60. 70
      app/controllers/concerns/document_search.rb
  61. 64
      app/controllers/concerns/jurisprudence_search.rb
  62. 2
      app/controllers/concerns/subject_search.rb
  63. 7
      app/controllers/decisions_controller.rb
  64. 17
      app/controllers/doctrine/annotations_controller.rb
  65. 54
      app/controllers/doctrines_controller.rb
  66. 7
      app/controllers/document/doctrines_controller.rb
  67. 16
      app/controllers/documents_controller.rb
  68. 52
      app/controllers/jurisprudence/doctrines_controller.rb
  69. 17
      app/controllers/reports_controller.rb
  70. 83
      app/javascript/controllers/annotations_controller.js
  71. 24
      app/javascript/controllers/application_controller.js
  72. 206
      app/javascript/controllers/doctrines_controller.js
  73. 26
      app/javascript/controllers/document_controller.js
  74. 17
      app/javascript/controllers/reports_controller.js
  75. 29
      app/javascript/controllers/selectize_controller.js
  76. 52
      app/javascript/controllers/subjects_controller.js
  77. 0
      app/javascript/images/.keep
  78. BIN
      app/javascript/images/application/bg2.png
  79. BIN
      app/javascript/images/application/cdao-bg.png
  80. BIN
      app/javascript/images/application/cdasiaonline_logo.png
  81. BIN
      app/javascript/images/application/search-icon.png
  82. 40
      app/javascript/packs/application.js
  83. 144
      app/javascript/packs/application/footnotes.js
  84. 52
      app/javascript/src/application.scss
  85. 31
      app/javascript/src/application/document-search.scss
  86. 16
      app/javascript/src/application/nav-bar.scss
  87. 125
      app/javascript/src/application/offcanvas.scss
  88. 28
      app/javascript/src/application/pagination.scss
  89. 17
      app/javascript/src/application/sessions.scss
  90. 69
      app/javascript/src/application/sidenav.scss
  91. 38
      app/javascript/src/application/subject-accordion.scss
  92. 66
      app/jobs/parse_linkable_content_job.rb
  93. 17
      app/models/annotation.rb
  94. 2
      app/models/cdao/citation_finder.rb
  95. 23
      app/models/cdao/document.rb
  96. 16
      app/models/cdao/jurisprudence.rb
  97. 39
      app/models/cdao/subject.rb
  98. 149
      app/models/doctrine.rb
  99. 7
      app/models/doctrine_jurisprudence.rb
  100. 22
      app/reflexes/annotation_reflex.rb
  101. Some files were not shown because too many files have changed in this diff Show More

1
.dockerignore

@ -0,0 +1 @@
/docker/data

2
.github/workflows/deployment.yml

@ -1,6 +1,8 @@
name: Deployment
on:
push:
branches:
- stable
tags:
- v*
workflow_dispatch:

4
.gitignore vendored

@ -31,6 +31,7 @@
# Ignore master key for decrypting credentials and more.
/config/master.key
/config/credentials/*.key
/public/packs
/public/packs-test
@ -43,3 +44,6 @@ db/schema.rb
.env*
!.env.sample
docker/*
!docker/.keep

1
Procfile

@ -1,2 +1,3 @@
web: rails s
webpack: ./bin/webpack-dev-server
worker: bundle exec sidekiq -q default,2 -q mailers,1 -q active_storage_analysis,1 -q active_storage_purge,1 -q sunspot_index,1

1
Procfile-worker

@ -0,0 +1 @@
sidekiq: bundle exec sidekiq $SIDEKIQ_QUEUES

29
README.md

@ -1,24 +1,7 @@
# README
# Development
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
```
docker-compose up -d
bin/setup
foreman start
```

4
app/components/analysis_form_component/analysis_form_component.html.erb

@ -17,7 +17,7 @@
<div class="row">
<div class="col-sm-11 p-2">
<button type="button" class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button>
<button type="button" class="btn btn-success" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button>
</div>
</div>
@ -28,7 +28,7 @@
</div>
<div class="col-sm-1 p-2">
<%= button_tag "search", class: "btn btn-primary" %>
<%= button_tag "search", class: "btn btn-success" %>
</div>
</div>

51
app/components/annotation_form_component.rb

@ -0,0 +1,51 @@
class AnnotationFormComponent < BaseComponent
attr_reader :annotation, :opts
def initialize(current_user:, annotation:, opts: {})
@annotation = annotation
@opts = opts
end
def document
return annotation.document if annotation.persisted?
Cdao::Document.find(opts[:document_id].to_i)
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def display_text
return annotation.content if annotation.persisted? && annotation.content.present? && annotation.content.include?("Phil")
display_text = nil
title = document.short_title || document.title
year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year
if annotation.new_record?
display_text = [title, document.clean_reference_number, year_or_date].join(", ")
else
contents = [[title, document.clean_reference_number, year_or_date].reject(&:blank?).join(", ")]
annotation.documents.each do |citing_doc|
citing_doc_title = citing_doc.short_title || citing_doc.title
citing_doc_year_or_date = citing_doc.doc_date.present? ? citing_doc.doc_date.strftime("%B %d, %Y") : citing_doc.year
contents << [citing_doc_title, citing_doc.clean_reference_number, citing_doc_year_or_date].join(", ")
end
display_text = contents.reject(&:blank?).join(" citing ")
end
display_text
end
def phil_rep
return annotation.phil_rep if annotation.persisted?
document.phil_rep
end
end

51
app/components/annotation_form_component/annotation_form_component.html.erb

@ -0,0 +1,51 @@
<div class="row">
<div class="col-sm-12 p-2">
<strong> Annotation Marks </strong>
<%= hidden_field_tag :document_ids, annotation.citing_document_ids, data: { target: "annotations.document_ids" } %>
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all.order(name: :asc), :id, :name, annotation.annomark_ids),
class: "form-control default-selectize ps-0", multiple: true, prompt: "Please select" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :document_title %> </strong>
<%= rich_text_area_tag :content, display_text, placeholder: "Document Title" %>
</div>
</div>
<div id="annotatedDocumentsSearchResults">
<div class="row">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "annotations.q" } %>
</div>
<div class="col-sm-1 p-2">
<button type="button" class="btn btn-success" data-action="click->annotations#searchDocuments"> Search </button>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :phil_rep %> </strong>
<%= text_field_tag :phil_rep, phil_rep, class: "form-control", data: { target: "annotations.phil_rep" } %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, annotation.editor_notes, placeholder: "Editor's Note", data: { target: "annotations.editor_notes" } %>
</div>
</div>

6
app/components/annotation_marks_modal_form_component.rb

@ -1,4 +1,6 @@
class AnnotationMarksModalFormComponent < BaseComponent
def initialize(current_user:); end
attr_reader :opts
def initialize(current_user:, opts: {})
@opts = opts
end
end

19
app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb

@ -1,4 +1,4 @@
<div class="modal fade modal-doctrine-body" id="annotationModal" tabindex="-1" aria-labelledby="annotationModal" aria-hidden="true" data-controller="annotations">
<div class="modal fade modal-doctrine-body" id="annotationModal" tabindex="-1" aria-labelledby="annotationModal" data-controller="annotations">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
@ -11,6 +11,7 @@
<div class="col-sm-12 p-2">
<strong> <%= label_tag :annotation_marks %> </strong>
<%= hidden_field_tag :annotation_id, nil, data: { target: "annotations.annotation_id" } %>
<%= hidden_field_tag :current_document_id, nil, data: { target: "annotations.current_document_id" } %>
<%= hidden_field_tag :doctrine_id, nil, data: { target: "annotations.doctrine_id" } %>
<%= hidden_field_tag :document_id, nil, data: { target: "annotations.document_id" } %>
<%= hidden_field_tag :document_ids, nil, data: { target: "annotations.document_ids" } %>
@ -27,12 +28,13 @@
</div>
</div>
<div id="annotatedDocumentsSearchResults">
<div class="row">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number", data: { target: "annotations.q" } %>
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "annotations.q" } %>
</div>
<div class="col-sm-1 p-2">
<button type="button" class="btn btn-primary" data-action="click->annotations#searchDocument"> Search </button>
<button type="button" class="btn btn-success" data-action="click->annotations#searchDocuments"> Search </button>
</div>
</div>
@ -44,10 +46,9 @@
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
<tbody id="documentSearchResultTable"> </tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
@ -58,15 +59,15 @@
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :editor_notes %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor Notes", data: { target: "annotations.editor_notes" } %>
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor's Note", data: { target: "annotations.editor_notes" } %>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-action="click->annotations#save"> Save </button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" data-action="click->annotations#save"> Save </button>
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>

8
app/components/document_index_table_component.rb → app/components/citation_index_table_component.rb

@ -1,4 +1,4 @@
class DocumentIndexTableComponent < BaseComponent
class CitationIndexTableComponent < BaseComponent
with_collection_parameter :search_result
attr_reader :search_result, :opts
@ -20,4 +20,10 @@ class DocumentIndexTableComponent < BaseComponent
def doctrine_annotations_path(doctrine_id)
doctrine_annotations_path(doctrine_id: doctrine_id)
end
def citator_path
return document_path(search_result.document.id) if search_result.document.present?
document_path(search_result.id)
end
end

7
app/components/citation_index_table_component/citation_index_table_component.html.erb

@ -0,0 +1,7 @@
<tr class="clickable-tr" data-controller="application"
data-href="<%= citator_path %>"
data-action="click->application#openLinkToNewTab">
<td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>
</tr>

10
app/components/doctrine_form_component.rb

@ -0,0 +1,10 @@
class DoctrineFormComponent < BaseComponent
attr_reader :doctrine, :jurisprudence_id, :opts
def initialize(current_user:, doctrine:, jurisprudence_id:, opts: {})
@doctrine = doctrine
@jurisprudence_id = jurisprudence_id
@opts = opts
end
end

38
app/components/doctrine_form_component/doctrine_form_component.html.erb

@ -0,0 +1,38 @@
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label"> Subjects </label>
<%= hidden_field_tag :document_id, jurisprudence_id, data: { target: "doctrines.document_id" } %>
<%= hidden_field_tag :doctrine_id, doctrine.id, data: { target: "doctrines.doctrine_id" } %>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true" required>
<% doctrine.subjects.each do |subject| %>
<option value="<%= subject.id %>" selected> <%= subject.lineage_name %> </option>
<% end if doctrine.persisted? %>
</select>
<div class="invalid-feedback" id="subjects-blank-message"> Subject/s cannot be blank. </div>
</div>
</div>
<% if doctrine.new_record? %>
<div class="row" id="doctine_content_suggestions_div">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Doctine content suggestions</label>
<select id="doctine_content_suggestions" class="form-control ps-0"> </select>
</div>
</div>
<% end %>
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Head Note</label>
<%= text_field_tag :headnote, doctrine.headnote, class: "form-control", placeholder: "Head note", required: true, data: { target: "doctrines.headnote" } %>
<div class="invalid-feedback" id="headnote-blank-message"> Headnote cannot be blank. </div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Content</label>
<%= rich_text_area_tag :content, doctrine.content, placeholder: "Doctrine Content", required: true, data: { target: "doctrines.content" } %>
<div class="invalid-feedback" id="content-blank-message"> Content cannot be blank. </div>
<div>
</div>

65
app/components/doctrine_index_component.rb

@ -0,0 +1,65 @@
class DoctrineIndexComponent < BaseComponent
attr_reader :search_results, :opts
include AnnotationSearch
include DoctrineSearch
def initialize(search_results:, current_user:, opts: {})
@search_results = search_results
@opts = opts
end
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
end
def subject_names
"(No Subjects Provided)"
end
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
annotation.document.title
end
def date_or_year(annotation)
return annotation.document.docdate.to_date.strftime("%B %d, %Y") if annotation.document.docdate.present?
annotation.document.year
end
def doctrine_show_url
return document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) if jurisprudence.present?
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def search_annotations(search_params)
search = annotation_search(search_params)
search.results
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def search_doctrines(search_params)
search = doctrine_search(search_params)
search
end
def render?
search_results.present?
end
end

58
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -0,0 +1,58 @@
<div class="row-flex m-3 mt-0 doctrine-content-body">
<div class="container-sm <%= params[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<% search_results.uniq(&:headnote).each do |uniq_by_headnote| %>
<h5> <%= uniq_by_headnote.headnote %> </h5>
<% grouped_by_content_search_params = { subject_ids: opts[:subject_ids], headnote: uniq_by_headnote.headnote, is_grouped_by_content: true } %>
<% search_doctrines(grouped_by_content_search_params).group(:content).groups.each do |group_by_content| %>
<% group_by_content.results.each do |content_result| %>
<div class="mb-0 fs-5"> <%= raw content_result.content.html_safe %> </div>
<% grouped_by_juris_search_params = { subject_ids: opts[:subject_ids], content: content_result.content, is_grouped_by_juris_id: true } %>
<% search_doctrines(grouped_by_juris_search_params).group(:jurisprudence_id).groups.each do |grouped_by_juris| %>
<% grouped_by_juris.results.each do |juris_result| %>
<h5 class="clickable-link" style="color: darkred;" data-controller="application"
data-href="<%= document_path(juris_result.jurisprudence.document.id, is_index_table: false, subject_ids: params[:subject_ids]) %>"
data-action="click->application#openLink">
<% document_title = juris_result.jurisprudence.short_title || juris_result.jurisprudence.title %>
<% date_or_year = juris_result.jurisprudence.doc_date.present? ? juris_result.jurisprudence.doc_date.strftime("%B, %d, %Y") : doctrine.jurisprudence.year %>
<%= [document_title, juris_result.jurisprudence.clean_reference_number, date_or_year].join(", ") %>
</h5>
<% search_params = { subject_ids: opts[:subject_ids], headnote: uniq_by_headnote.headnote, content: content_result.content, jurisprudence_id: juris_result.jurisprudence.id } %>
<% search_doctrines(search_params).results.each do |doctrine| %>
<% search_annotations({ doctrine_id: doctrine.id }).each do |annotation| %>
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.doc_date.present? ? annotated_document.doc_date.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
<hr/>
</div>

6
app/components/doctrine_index_table_component.rb

@ -6,6 +6,12 @@ class DoctrineIndexTableComponent < BaseComponent
@opts = opts
end
def jurisprudence(search_result)
return "(No Assigned Document)" if search_result.doctrine_jurisprudences.blank?
search_result.doctrine_jurisprudences.first.jurisprudence
end
def document_reference_number(document)
document.reference_number
end

10
app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb

@ -7,10 +7,12 @@
<tbody>
<% search_results.each do |search_result| %>
<tr href="<%= document_path(search_result.document_id) %>" class="clickable-tr">
<td> <%= document_reference_number(search_result.document) %> </td>
<td> <%= document_title(search_result.document) %> </td>
<td> <%= date_or_year(search_result.document) %> </td>
<tr class="clickable-link" data-controller="application"
data-href="<%= document_path(search_result.document.id, is_index_table: true, subject_ids: opts[:subject_ids]) %>"
data-action="click->application#openLink">
<td> <%= document_reference_number(search_result) %> </td>
<td> <%= document_title(search_result) %> </td>
<td> <%= date_or_year(search_result) %> </td>
</tr>
<% end %>
</tbody>

16
app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb

@ -11,7 +11,8 @@
<label for="subject-name" class="col-form-label"> Subjects </label>
<%= hidden_field_tag :document_id, nil, data: { target: "doctrines.document_id" } %>
<%= hidden_field_tag :doctrine_id, nil, data: { target: "doctrines.doctrine_id" } %>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true" required> </select>
<div class="invalid-feedback" id="subjects-blank-message"> Subject/s cannot be blank. </div>
</div>
<div class="mb-3" id="doctine_content_suggestions_div">
@ -19,14 +20,21 @@
<select id="doctine_content_suggestions" class="form-control ps-0"> </select>
</div>
<div class="mb-3">
<label for="subject-name" class="col-form-label">Head Note</label>
<%= text_field_tag :headnote, nil, class: "form-control", placeholder: "Head note", required: true, data: { target: "doctrines.headnote" } %>
<div class="invalid-feedback" id="headnote-blank-message"> Headnote cannot be blank. </div>
</div>
<div class="mb-3">
<label for="subject-name" class="col-form-label">Content</label>
<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", data: { target: "doctrines.content" } %>
<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", required: true, data: { target: "doctrines.content" } %>
<div class="invalid-feedback" id="content-blank-message"> Content cannot be blank. </div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-action="click->doctrines#save">Save</button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" data-action="click->doctrines#save">Save</button>
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>

39
app/components/doctrines_offcanvas_accordion_component.rb

@ -0,0 +1,39 @@
class DoctrinesOffcanvasAccordionComponent < BaseComponent
with_collection_parameter :search_result
attr_reader :search_result, :opts
def initialize(search_result:, current_user:, opts: {})
@search_result = search_result
@opts = opts
end
def accordion_name
"doctrinesOffCanvasAccordion"
end
def accordion_body_name
"doctrinesOffCanvasAccordionBody"
end
def parent_accordion_id
return accordion_body_name if search_result["parent_id"].blank?
[accordion_name, search_result["parent_id"]].join
end
def children_accordion_id
[accordion_name, search_result["heirarchy_level"], search_result["id"]].join
end
def accordion_id
[accordion_name, search_result["id"]].join
end
def accordion_body_id
[accordion_body_name, search_result["id"]].join
end
def index_url
search_doctrines_path(subject_ids: [search_result["id"]], is_index_table: false)
end
end

27
app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb

@ -0,0 +1,27 @@
<div class="accordion accordion-flush offcanvas-item" id="<%= accordion_id %>">
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if search_result["has_children?"].present? %>
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadDoctrinesOffcanvasAccordion">
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
</div>
<% else %>
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= children_accordion_id %>" data-bs-parent="#<%= accordion_id %>">
<div class="accordion-body pt-1 sub-body<%= search_result["heirarchy_level"] + 1 %> pb-1" id="<%= accordion_body_id %>">
<div class="text-center">
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
</div>

11
app/components/doctrines_offcanvas_component.rb

@ -0,0 +1,11 @@
class DoctrinesOffcanvasComponent < BaseComponent
attr_reader :opts
def initialize(current_user:, opts: {})
@opts = opts
end
def render?
opts[:is_render].present?
end
end

40
app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb

@ -0,0 +1,40 @@
<div class="offcanvas offcanvas-start offcanvas-contents" data-bs-scroll="true" tabindex="-1" data-bs-backdrop="false" id="doctrinesOffCanvas" data-controller="subjects">
<div class="offcanvas-header">
<h5 class="offcanvas-title"> Doctrines </h5>
<hr class="m-0">
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="accordion accordion-flush subject-index-body" id="doctrinesOffCanvasMainAccordion" >
<% Cdao::Subject.roots.order(name: :asc).each do |root| %>
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if root.children.present? %>
<div class="accordion-button collapsed m-0 p-0" data-bs-toggle="collapse" data-bs-target="#<%= ["doctrinesOffCanvasAccordion", root.id].join %>"
data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['doctrinesOffCanvasAccordionBody', root.id].join %>"
data-action="click->subjects#loadDoctrinesOffcanvasAccordion">
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_doctrines_path(subject_ids: [root.id], is_index_table: false), action: "click->application#openLink" } %>
</div>
<% else %>
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_doctrines_path(subject_ids: [root.id], is_index_table: false), action: "click->application#openLink" } %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= ["doctrinesOffCanvasAccordion", root.id].join %>" data-bs-parent="#doctrinesOffCanvasMainAccordion">
<div class="accordion-body pt-1 pb-1 sub-body1" id="<%= ["doctrinesOffCanvasAccordionBody", root.id].join %>">
<div class="text-center">
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>

13
app/components/document_advanced_search_component.rb

@ -0,0 +1,13 @@
class DocumentAdvancedSearchComponent < BaseComponent
attr_reader :opts
def initialize(current_user:, opts: {})
@opts = opts
end
def years
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :asc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
(start_year..end_year).entries.reverse
end
end

36
app/components/document_advanced_search_component/document_advanced_search_component.html.erb

@ -0,0 +1,36 @@
<%= form_tag(documents_path, method: :get) do %>
<div class="mb-2">
<%= text_field_tag :q, params[:q], placeholder: 'Full text search', class: "form-control mb-0" %>
</div>
<hr class="simple mb-0">
<div class="mb-2">
<label for="exampleFormControlInput1" class="form-label text-white">G.R. Number</label>
<%= text_field_tag :reference_number, params[:reference_number], class: "form-control mb-0" %>
</div>
<div class="mb-2">
<label for="exampleFormControlInput1" class="form-label text-white">Title</label>
<%= text_field_tag :title, params[:title], class: "form-control mb-0" %>
</div>
<div class="d-flex align-items-end">
<div class="mb-2 w-100 pe-2">
<label for="exampleFormControlInput1" class="form-label text-white">Year</label>
<%= select_tag :year_start, options_for_select(years, params[:year_start]), class: "form-select", include_blank: true %>
</div>
<div class="mb-2 w-100 ps-2">
<%= select_tag :year_end, options_for_select(years, params[:year_end]), class: "form-select", include_blank: true %>
</div>
</div>
<hr class="simple mb-0">
<div class="mb-2">
<label for="exampleFormControlInput1" class="form-label text-white">Citation Finder</label>
<%= text_field_tag :citation_finder, params[:citation_finder], class: "form-control mb-0" %>
</div>
<div class="d-flex justify-content-end mt-3">
<button class="btn btn-success reset-document-advanced-search me-2 mb-2"><i class="fas fa-sync"></i> Refresh</button>
<button type="submit" class="btn btn-danger mb-2">Search</button>
</div>
<% end %>

35
app/components/document_doctrine_index_component.rb

@ -2,6 +2,8 @@ class DocumentDoctrineIndexComponent < BaseComponent
with_collection_parameter :doctrine
attr_reader :doctrine, :opts
include AnnotationSearch
def initialize(doctrine:, current_user:, opts: {})
@doctrine = doctrine
@opts = opts
@ -10,13 +12,9 @@ class DocumentDoctrineIndexComponent < BaseComponent
delegate :id, to: :doctrine
delegate :subject_ids, to: :doctrine
delegate :content, to: :doctrine
delegate :document_id, to: :doctrine
delegate :annotations, to: :doctrine
delegate :subjects, to: :doctrine
def doctrine_form_url
jurisprudence_doctrines_path(jurisprudence_id: document_id)
end
delegate :headnote, to: :doctrine
delegate :doctrine_jurisprudences, to: :doctrine
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
@ -26,6 +24,12 @@ class DocumentDoctrineIndexComponent < BaseComponent
"(No Subjects Provided)"
end
def jurisprudence
return nil if doctrine_jurisprudences.blank?
doctrine_jurisprudences.first.jurisprudence
end
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
@ -38,6 +42,25 @@ class DocumentDoctrineIndexComponent < BaseComponent
annotation.document.year
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def annotations
search = annotation_search(doctrine_id: id)
search.results
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def render?
doctrine.present? && doctrine.persisted?
end

42
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -1,43 +1,35 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= opts[:is_disable_clickable_link].present? ? '#' : document_doctrine_path(document_id, id)%>">
<% if opts[:is_subjects_index].blank? %>
<% if opts[:is_doctrines_index].present? && opts[:subject_ids].reject(&:blank?).present? %>
<h5 style="color: darkred;"> <%= subjects.where(id: opts[:subject_ids].map(&:to_i)).map(&:lineage_name).join(" ") %> </h5>
<% elsif subjects.present? %>
<% subjects.each do |subject| %>
<h5 style="color: darkred;"> <%= subject.lineage_name %> </h5>
<% end %>
<% else %>
<h5> (No Subjects Provided) </h5>
<% end %>
<% end %>
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" data-controller="application"
data-href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"
data-action="click->application#openLink">
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<span> <b> <i> <%= headnote %> </i> </b> </span>
<p class="mb-0"> <%= raw content.html_safe %> </p>
<div class="container-sm ms-3">
<% annotations.each do |annotation| %>
<div class="container-fluid p-0">
<% if opts[:is_doctrines_index].present? %>
<% document_title = annotation.doctrine.document.short_title || annotation.doctrine.document.title %>
<% date_or_year = annotation.doctrine.document.docdate.present? ? annotation.doctrine.document.docdate.to_date.strftime("%B %d, %Y") : annotation.document.year %>
<span> <%= [document_title, annotation.document.reference_number, date_or_year].join(", ") %> </span>
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.clean_reference_number, date_or_year].join(", ") %> </h5>
<% end %>
<p class="mb-0 ms-3">
<% annotations.each do |annotation| %>
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">

43
app/components/document_doctrine_show_component.rb

@ -1,28 +1,20 @@
class DocumentDoctrineShowComponent < BaseComponent
attr_reader :current_user, :doctrine, :subjects
attr_reader :current_user, :doctrine, :opts
def initialize(current_user:, doctrine:, subjects:, opts: {})
include AnnotationSearch
def initialize(current_user:, doctrine:, opts: {})
@doctrine = doctrine
@current_user = current_user
@subjects = subjects
@opts = opts
end
delegate :id, to: :doctrine
delegate :headnote, to: :doctrine
delegate :subject_ids, to: :doctrine
delegate :content, to: :doctrine
delegate :document_id, to: :doctrine
delegate :document, to: :doctrine
delegate :annotations, to: :doctrine
delegate :subjects, to: :doctrine
def doctrine_form_url
jurisprudence_doctrines_path(jurisprudence_id: document_id)
end
def edit_doctrine_form_url
jurisprudence_doctrines_path(jurisprudence_id: document_id, id: id)
end
def annotation_form_url
doctrine_annotations_path(doctrine_id: id,)
end
@ -33,8 +25,8 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.title
end
def all_subjects
Cdao::Subject.all.order(name: :asc)
def jurisprudence
Cdao::Jurisprudence.find(opts[:jurisprudence_id])
end
def date_or_year(annotation)
@ -42,4 +34,23 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.year
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def annotations
search = annotation_search(doctrine_id: id)
search.results
end
end

71
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -5,9 +5,9 @@
<h5> <b>Doctrine Details</b> </h5>
</div>
<div class="col-sm-2 d-flex justify-content-end pe-0">
<a class="btn btn-sm btn-secondary me-3" data-controller="doctrines" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>" data-action="click->doctrines#renderForm" data-bs-toggle="modal" data-bs-target="#doctrineModal"> Edit </a>
<a class="btn btn-sm btn-danger" href="<%= jurisprudence_doctrine_path(document_id, id) %>" data-confirm="Are you sure to delete this record?" data-method="DELETE"> Delete </a>
<div class="col-sm-2 d-flex justify-content-end pe-0" >
<a class="btn btn-success me-3 for-selectize-edit" href="<%= edit_doctrine_path(id, jurisprudence_id: opts[:jurisprudence_id]) %>"> Edit </a>
<a class="btn btn-danger " data-controller="doctrines" data-doctrine-id="<%= id %>" data-document-id="<%= jurisprudence.document.id %>" data-action="click->doctrines#delete" > Delete </a>
</div>
</div>
@ -19,7 +19,7 @@
<div class="card-body pt-0">
<div class="row">
<div class="col-sm-2" style="width: 100px;">
<div class="col-sm-2" style="width: 120px;">
<strong> Subjects: </strong>
</div>
@ -29,7 +29,17 @@
</div>
<div class="row">
<div class="col-sm-2" style="width: 100px;">
<div class="col-sm-2" style="width: 120px;">
<strong> Head Note: </strong>
</div>
<div class="col-sm-10">
<%= headnote %>
</div>
</div>
<div class="row">
<div class="col-sm-2" style="width: 120px;">
<strong> Content: </strong>
</div>
@ -41,30 +51,32 @@
<div class="row">
<div class="col-sm-10"> </div>
<div class="col-sm-2 p-2">
<button type="button" class="btn btn-primary d-block ms-auto" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button>
<button type="button" class="btn btn-info d-block ms-auto text-white" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case List </button>
</div>
</div>
<div class="collapse mb-3 mt-2" id="caseListsCollapse">
<div class="row" data-controller="document" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>">
<div class="col-sm-11 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number", data: { target: "document.input" } %>
<div class="row" data-controller="document" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
</div>
<div class="col p-2">
<%= button_tag "Search", class: "btn btn-primary", data: { action: "click->document#search" } %>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success btn-sm me-2", data: { action: "click->document#search" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, nil, class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
</div>
</div>
<div class="row tab">
<div class="col-sm-12default-pagination"> </div>
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
<tbody id="documentIndexTable"> </tbody>
</table>
</div>
</div>
@ -72,39 +84,34 @@
<div class="row-flex">
<div class="annot-header"> <h5> Annotations </h5> </div>
<div class="">
<% doctrine.annotations.order(rank: :asc).each do |annotation| %>
<div class="" id="annotationsIndexView">
<% annotations.each do |annotation| %>
<% document_title = annotation.document.short_title || annotation.document.title %>
<% date_or_year = annotation.document.docdate.present? ? annotation.document.docdate.strftime("%B %d, %Y") : annotation.document.year %>
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<div class="row">
<div class="col-sm-10">
<p class="pb-0 ms-3">
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw citing_document_title %>
</p>
</div>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
<div class="col-sm-2 d-flex justify-content-end align-items-baseline">
<a class="btn btn-sm btn-secondary me-3" data-bs-toggle="modal" data-bs-target="#annotationModal"
data-controller="annotations" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>"
data-document-title="<%= citing_document_title %>"
data-action="click->annotations#renderForm"> Edit </a>
<a class="btn btn-sm btn-danger" href="<%= doctrine_annotation_path(doctrine.id, annotation.id) %>" data-confirm="Are you sure to delete this record?" data-method="DELETE"> Delete </a>
<a class="btn btn-secondary btn-sm me-1" href="<%= edit_doctrine_annotation_path(annotation.doctrine_id, annotation.id, jurisprudence_id: opts[:jurisprudence_id], document_id: annotation.document_id) %>">
Edit
</a>
<a class="btn btn-danger btn-sm ms-1" data-controller="annotations" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" data-action="click->annotations#delete" > Delete </a>
</div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row">
<div class="row mb-2">
<div class="col-sm-1 ms-5 p-0" style="width: 105px;">
<span> Editors Note: </span>
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">

5
app/components/document_index_table_component/document_index_table_component.html.erb

@ -1,5 +0,0 @@
<tr href="<%= document_path(search_result.id) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-tr' : ''%>" target="_blank">
<td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>
</tr>

2
app/components/documents_years_component/documents_years_component.html.erb

@ -4,7 +4,7 @@
<td>
<div class="container-sm p-0">
<% year_arr.each do |year| %>
<strong> <%= link_to year, documents_path(year: year.to_i), class: "text-decoration-none text-dark d-block" %> </strong>
<strong> <%= link_to year, documents_path(year_start: year.to_i, year_end: year.to_i), class: "text-decoration-none text-dark d-block" %> </strong>
<% end %>
</div>
</td>

25
app/components/jurisprudences_index_table_component.rb

@ -0,0 +1,25 @@
class JurisprudencesIndexTableComponent < BaseComponent
with_collection_parameter :jurisprudence
attr_reader :jurisprudence, :opts
def initialize(jurisprudence:, current_user:, opts: {})
@jurisprudence = jurisprudence
@opts = opts
end
delegate :id, to: :jurisprudence
delegate :clean_reference_number, to: :jurisprudence
delegate :title, to: :jurisprudence
delegate :short_title, to: :jurisprudence
delegate :document, to: :jurisprudence
def date_or_year
return jurisprudence.docdate.strftime("%B %d, %Y") if jurisprudence.docdate.present?
jurisprudence.year
end
def doctrine_annotations_path(doctrine_id)
doctrine_annotations_path(doctrine_id: doctrine_id)
end
end

6
app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb

@ -0,0 +1,6 @@
<tr class="clickable-link" data-controller="application" data-href="<%= document_path(document.id) %>"
data-action="click->application#openLink">
<td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>
</tr>

8
app/components/pagination_component.rb

@ -10,4 +10,12 @@ class PaginationComponent < BaseComponent
Cdao::Subject.where(id: opts[:subject_ids].map(&:to_i))
end
def custom_url(id)
return search_doctrines_path(is_index_table: true, subject_ids: [id]) if opts[:is_index_table].present? && opts[:is_index_table].to_s.eql?("true")
return search_doctrines_path( is_index_table: false, subject_ids: [id]) if opts[:is_index_table].present? && opts[:is_index_table].to_s.eql?("false")
search_doctrines_path(id)
end
end

15
app/components/pagination_component/pagination_component.html.erb

@ -1,16 +1,14 @@
<div class="col col-md-12">
<header class="header bg-white b-b clearfix">
<header class="header bg-white b-b clearfix">
<div class="row m-t-sm align-items-end pagination-body">
<div class="col-md-6 mb-0<%=opts[:is_subject_breadcrums].present? && subjects.present? ? '' : ' ps-0' %> ">
<div class="<%=data.present? ? "col-md-8 mb-0 " : "col-md-12 mb-0"%> <%= opts[:is_cited_in_doc].present? ? 'd-none': ""%> ">
<% if opts[:is_subject_breadcrums].present? && subjects.present? %>
<ol class="breadcrumb mb-0">
<% subjects.each do |subject| %>
<% subject.ancestors.each do |ancestor| %>
<li class="breadcrumb-item d-inline-flex">
<h4> <%= link_to ancestor.name, subject_index_path(ancestor), class: "text-decoration-none" %> </h4>
<h4 class="label-breadcrumb"> <%= link_to ancestor.name, custom_url(ancestor.id), class: "text-decoration-none" %> </h4>
</li>
<% end %>
<li class="breadcrumb-item d-inline-flex active">
<h4> <%= subject.name %> </h4>
</li>
@ -23,11 +21,10 @@
</small>
<% end %>
</div>
<div class="col-md-6 position-relative">
<div class="text-center pagination justify-content-end">
<div class="<%=data.present? ? "col-md-4 position-relative" : "d-none"%>">
<div class="text-center pagination justify-content-end me-3">
<%= (paginate data) if data.present? %>
</div>
</div>
</div>
</header>
</div>
</header>

47
app/components/reports_search_results_component.rb

@ -0,0 +1,47 @@
class ReportsSearchResultsComponent < BaseComponent
with_collection_parameter :search_result
attr_reader :search_result, :opts
def initialize(search_result:, current_user:, opts: {})
@search_result = search_result
@opts = opts
end
delegate :id, to: :search_result
delegate :headnote, to: :search_result
delegate :subject_ids, to: :search_result
delegate :content, to: :search_result
delegate :annotations, to: :search_result
delegate :subjects, to: :search_result
delegate :doctrine_jurisprudences, to: :search_result
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
end
def subject_names
"(No Subjects Provided)"
end
def jurisprudence
return nil if doctrine_jurisprudences.blank?
doctrine_jurisprudences.first.jurisprudence
end
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
annotation.document.title
end
def date_or_year(annotation)
return annotation.document.docdate.to_date.strftime("%B %d, %Y") if annotation.document.docdate.present?
annotation.document.year
end
def render?
opts[:is_render].present?
end
end

42
app/components/reports_search_results_component/reports_search_results_component.html.erb

@ -0,0 +1,42 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" data-controller="application"
data-href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"
data-action="click->application#openLink">
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
<div class="container-fluid p-0">
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.strftime : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-5">
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% end %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<hr/>
</div>

5
app/components/sidenav_component.rb

@ -1,5 +1,8 @@
class SidenavComponent < BaseComponent
def initialize(current_user:)
attr_reader :current_user, :opts
def initialize(current_user:, opts: {})
@current_user = current_user
@opts = opts
end
end

43
app/components/sidenav_component/sidenav_component.html.erb

@ -1,4 +1,6 @@
<% if current_user.present? %>
<% if opts[:is_sidenav].present? %>
<div class="col-auto col-md-3 col-xl-2 px-sm-2 px-0 bg-secondary min-vh-100" style="padding: 0 !important;">
<div class="sidebar sidebar-body d-flex flex-column align-items-center align-items-sm-start pt-2 text-white min-vh-100">
<ul class="nav flex-column text-white w-100">
<a href="/" class="nav-link d-flex align-items-center h3 text-white my-2 w-100">
@ -69,4 +71,45 @@
</li>
</ul>
</div>
</div>
<% elsif opts[:is_nav_bar].present? %>
<nav class="navbar navbar-expand-lg navbar-light bg-light p-0 navbar-body">
<div class="container-fluid">
<div class="collapse navbar-collapse justify-content-between" id="navbarSupportedContent">
<div>
<a class="navbar-brand" href="#"><%= image_pack_tag 'application/cdasiaonline_logo.png', class:"nav-bar-app-logo" %></a>
</div>
<form class="d-flex">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item p-2">
<%= link_to '<i class="fas fa-search me-2"></i>Search'.html_safe, documents_path, class: "nav-link" %>
</li>
<li class="nav-item p-2">
<a class="nav-link" style="cursor: pointer" data-bs-toggle="offcanvas" data-bs-target="#subjectsOffCanvas">
<i class="fas fa-indent me-2"></i> Subjects
</a>
</li>
<li class="nav-item p-2" style="cursor: pointer">
<a class="nav-link" data-bs-toggle="offcanvas" data-bs-target="#doctrinesOffCanvas">
<i class="fas fa-book me-2"></i> Doctrines
</a>
</li>
<li class="nav-item p-2">
<%= link_to '<i class="fas fa-map-signs me-2"></i> Decisions'.html_safe, decisions_path, class: "nav-link" %>
</li>
<li class="nav-item p-2">
<%= link_to '<i class="fas fa-cog me-2"></i>Settings'.html_safe, subject_indexes_path, class: "nav-link" %>
</li>
<li class="nav-item p-2">
<%= link_to '<i class="fa-solid fa-file-lines"></i>Reports'.html_safe, reports_path, class: "nav-link" %>
</li>
<li class="nav-item p-2 active-red">
<%= link_to '<i class="fas fa-sign-out-alt"></i> Sign Out'.html_safe, destroy_user_session_path, class:" text-white nav-link" %>
</li>
</ul>
</form>
</div>
</div>
</nav>
<% end %>
<% end %>

8
app/components/subject_accordion_component.rb

@ -1,8 +0,0 @@
class SubjectAccordionComponent < BaseComponent
attr_reader :parent
def initialize(current_user:, parent:)
@parent = parent
end
end

76
app/components/subject_accordion_component/subject_accordion_component.html.erb

@ -1,76 +0,0 @@
<% parent.children.order(name: :asc).each do |sub1| %>
<div class="accordion accordion-flush ps-20" id="#secondLevelPanel<%= sub1.id %>">
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if sub1.children.present? %>
<div class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#<%= ["secondLevel", sub1.id].join %>">
<%= link_to sub1.name, subject_index_path(sub1.id), class: "accordion-link text-decoration-none text-dark d-block sub2 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub1.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to sub1.name, subject_index_path(sub1.id), class: "accordion-link text-decoration-none text-dark d-block sub2 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub1.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= ["secondLevel", sub1.id].join %>" data-bs-parent="#secondLevelPanel<%= sub1.id %>">
<div class="accordion-body pt-1">
<% sub1.children.order(name: :asc).each do |sub2| %>
<div class="accordion accordion-flush ps-20" id="thirdLevelPanel<%= sub2.id %>">
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if sub1.children.present? %>
<div class="accordion-button collapsed" data-bs-toggle="collapse" data-bs-target="#<%= ["thirdLevel", sub2.id].join %>">
<%= link_to sub2.name, subject_index_path(sub2.id), class: "accordion-link text-decoration-none text-dark d-block sub3 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub2.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to sub2.name, subject_index_path(sub2.id), class: "accordion-link text-decoration-none text-dark d-block sub3 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub2.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= ["thirdLevel", sub2.id].join %>" data-bs-parent="#thirdLevelPanel<%= sub2.id %>">
<div class="accordion-body pt-1">
<% sub2.children.order(name: :asc).each do |sub3| %>
<div class="accordion accordion-flush ps-20" id="fourthLevelPanel<%= sub3.id %>">
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if sub3.children.present? %>
<div class="<%= sub3.children.present? ? 'accordion-button' : '' %> collapsed" data-bs-toggle="collapse" data-bs-target="#<%= ["fourthLevel", sub3.id].join %>">
<%= link_to sub3.name, subject_index_path(sub3.id), class: "accordion-link text-decoration-none text-dark d-block sub4 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub3.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to sub3.name, subject_index_path(sub3.id), class: "accordion-link text-decoration-none text-dark d-block sub4 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub3.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= ["fourthLevel", sub3.id].join %>" data-bs-parent="#fourthLevelPanel<%= sub3.id %>">
<div class="accordion-body pt-1">
<% sub3.children.order(name: :asc).each do |sub4| %>
<div class="accordion accordion-flush ps-20">
<div class="accordion-item d-flex justify-content-between">
<div>
<%= link_to sub4.name, subject_index_path(sub4.id), class: "accordion-link text-decoration-none text-dark d-block sub5 clickable-link" %>
<%= link_to "Add Sub Level", new_subject_index_path(parent_id: sub4.id), class: "btn btn-sm btn-primary text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin" %>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
<% end %>

8
app/components/subject_index_form_component.rb

@ -4,11 +4,13 @@ class SubjectIndexFormComponent < BaseComponent
def initialize(current_user:, subject_index:, opts:)
@subject_index = subject_index
@opts = opts
@parent_id = @opts[:parent_id]
@parent_id = opts[:parent_id]
end
def all_subjects
Cdao::Subject.all.order(name: :asc)
def parent
return if parent_id.blank?
Cdao::Subject.find(parent_id)
end
def current_library

17
app/components/subject_index_form_component/subject_index_form_component.html.erb

@ -1,4 +1,4 @@
<%= form_for(subject_index, url: opts[:form_url], method: opts[:form_method]) do |form| %>
<%= form_for(subject_index, url: opts[:form_url], method: opts[:form_method], data: { reflex: "submut->SubjectsReflex#save" }) do |form| %>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :name %> </strong>
@ -7,18 +7,23 @@
</div>
</div>
<% if parent_id.present? %>
<% if parent_id.present? || subject_index.persisted? %>
<div cass="row">
<div class="col-sm-12 p-2">
<div class="col-sm-12">
<strong> <%= label_tag :subjects %> </strong>
<%= select_tag :parent_id, options_from_collection_for_select(all_subjects, :id, :lineage_name, parent_id), class: "form-select default-selectize", prompt: "Please select" %>
<select class="form-control subjects-selectize ps-0 pe-0" name="parent_id" id="parent_id">
<% if parent_id.present? %>
<option value="<%= parent_id %>" selected="selected"> <%= parent.name %> </option>
<% end %>
</select>
</div>
</div>
<% end %>
<div class="row">
<div class="col-sm-12 d-flex justify-content-end p-2">
<%= submit_tag "Save", class: "btn btn-primary" %>
<div class="col-sm-12 d-flex justify-content-end p-3">
<%= submit_tag "Save", class: "btn btn-success me-3" %>
<a type="button" class="btn btn-danger" href="<%= subject_indexes_path() %>"> Back </a>
</div>
</div>
<% end %>

38
app/components/subjects_accordion_component.rb

@ -0,0 +1,38 @@
class SubjectsAccordionComponent < BaseComponent
with_collection_parameter :search_result
attr_reader :search_result, :opts
def initialize(search_result:, current_user:, opts: {})
@search_result = search_result
@opts = opts
end
def accordion_name
"subjectsAccordion"
end
def accordion_body_name
"subjectsAccordionBody"
end
def parent_accordion_id
[accordion_name, search_result["parent_id"]].join
end
def children_accordion_id
[accordion_name, search_result["heirarchy_level"], search_result["id"]].join
end
def accordion_id
[accordion_name, search_result["id"]].join
end
def accordion_body_id
[accordion_body_name, search_result["id"]].join
end
def custom_url
subject_index_path(search_result["id"])
end
end

31
app/components/subjects_accordion_component/subjects_accordion_component.html.erb

@ -0,0 +1,31 @@
<div class="accordion accordion-flush" id="<%= accordion_id %>">
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if search_result["has_children?"].present? %>
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadSubjectsAccordion">
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: custom_url, action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]),
class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: custom_url, action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]),
class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 non-toggle" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= children_accordion_id %>" data-bs-parent="#<%= accordion_id %>">
<div class="accordion-body pt-1 sub-body<%= search_result["heirarchy_level"] + 1 %> pb-0" id="<%= accordion_body_id %>">
<div class="text-center">
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
</div>

39
app/components/subjects_offcanvas_accordion_component.rb

@ -0,0 +1,39 @@
class SubjectsOffcanvasAccordionComponent < BaseComponent
with_collection_parameter :search_result
attr_reader :search_result, :opts
def initialize(search_result:, current_user:, opts: {})
@search_result = search_result
@opts = opts
end
def accordion_name
"subjectsOffCanvasAccordion"
end
def accordion_body_name
"subjectsOffCanvasAccordionBody"
end
def parent_accordion_id
return accordion_body_name if search_result["parent_id"].blank?
[accordion_name, search_result["parent_id"]].join
end
def children_accordion_id
[accordion_name, search_result["heirarchy_level"], search_result["id"]].join
end
def accordion_id
[accordion_name, search_result["id"]].join
end
def accordion_body_id
[accordion_body_name, search_result["id"]].join
end
def index_url
search_documents_path(subject_ids: search_result["id"], is_index_table: true)
end
end

27
app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb

@ -0,0 +1,27 @@
<div class="accordion accordion-flush offcanvas-item" id="<%= accordion_id %>">
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if search_result["has_children?"].present? %>
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
</div>
<% else %>
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= children_accordion_id %>" data-bs-parent="#<%= accordion_id %>">
<div class="accordion-body pt-1 sub-body<%= search_result["heirarchy_level"] + 1 %> pb-1" id="<%= accordion_body_id %>">
<div class="text-center">
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
</div>

11
app/components/subjects_offcanvas_component.rb

@ -0,0 +1,11 @@
class SubjectsOffcanvasComponent < BaseComponent
attr_reader :opts
def initialize(current_user:, opts: {})
@opts = opts
end
def render?
opts[:is_render].present?
end
end

40
app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb

@ -0,0 +1,40 @@
<div class="offcanvas offcanvas-start offcanvas-contents" data-bs-scroll="true" tabindex="-1" data-bs-backdrop="false" id="subjectsOffCanvas" data-controller="subjects">
<div class="offcanvas-header">
<h5 class="offcanvas-title"> Subjects </h5>
<hr class="m-0">
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<div class="accordion accordion-flush subject-index-body" id="subjectsOffCanvasMainAccordion" >
<% Cdao::Subject.roots.order(name: :asc).each do |root| %>
<div class="accordion-item">
<div class="accordion-header d-flex justify-content-between">
<% if root.children.present? %>
<div class="accordion-button collapsed m-0 p-0" data-bs-toggle="collapse" data-bs-target="#<%= ["subjectsOffCanvasAccordion", root.id].join %>"
data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['subjectsOffCanvasAccordionBody', root.id].join %>"
data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_documents_path(subject_ids: root.id, is_index_table: true), action: "click->application#openLink" } %>
</div>
<% else %>
<%= link_to root.name, search_documents_path(subject_ids: root.id, is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_documents_path(subject_ids: root.id, is_index_table: true), action: "click->application#openLink" } %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= ["subjectsOffCanvasAccordion", root.id].join %>" data-bs-parent="#subjectsOffCanvasMainAccordion">
<div class="accordion-body pt-1 pb-1 sub-body1" id="<%= ["subjectsOffCanvasAccordionBody", root.id].join %>">
<div class="text-center">
<div class="spinner-border text-danger" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>

93
app/components/subjects_sidenav_sub_menu_component/subjects_sidenav_sub_menu_component.html.erb

@ -1,93 +0,0 @@
<div class="accordion-collapse collapse" id="<%= opts[:main_sub_menu] %>" data-bs-parent="#sidenav">
<div class="accordion-body pb-0 pe-0 pt-0">
<% Cdao::Subject.roots.order(name: :asc).each do |root| %>
<div class="accordion accordion-flush ps-20" id="firstLevelSubMenu">
<div class="accordion-item bg-transparent">
<div class="accordion-header bg-transparent">
<% if root.children.present? %>
<button class="<%= root.children.present? ? 'accordion-button' : '' %> collapsed bg-transparent" type="button" data-bs-toggle="collapse" data-bs-target="#<%= [opts[:second_sub_menu], root.id].join %>">
<%= link_to root.name, index_url(root.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub1 clickable-link" %>
</button>
<% else %>
<%= link_to root.name, index_url(root.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub1 clickable-link" %>
<% end %>
</div>
<% if root.children.present? %>
<div class="accordion-collapse collapse" id="<%= [opts[:second_sub_menu], root.id].join %>" data-bs-parent="#firstLevelSubMenu">
<div class="accordion-body pb-0 pe-0 pt-0">
<% root.children.order(name: :asc).each do |sub1| %>
<div class="accordion accordion-flush ps-20" id="secondLevelSubMenu">
<div class="accordion-item bg-transparent">
<div class="accordion-header bg-transparent">
<% if sub1.children.present? %>
<button class="<%= sub1.children.present? ? 'accordion-button' : '' %> collapsed bg-transparent" type="button" data-bs-toggle="collapse" data-bs-target="#<%= [opts[:third_sub_menu], sub1.id].join %>">
<%= link_to sub1.name, index_url(sub1.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub2 clickable-link" %>
</button>
<% else %>
<%= link_to sub1.name, index_url(sub1.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub2 clickable-link" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= [opts[:third_sub_menu], sub1.id].join %>" data-bs-parent="#secondLevelSubMenu">
<div class="accordion-body pb-0 pe-0 pt-0">
<% sub1.children.order(name: :asc).each do |sub2| %>
<div class="accordion accordion-flush" id="thirdLevelSubMenu">
<div class="accordion-item bg-transparent">
<div class="accordion-header bg-transparent">
<% if sub2.children.present? %>
<button class="<%= sub2.children.present? ? 'accordion-button' : '' %> collapsed bg-transparent" type="button" data-bs-toggle="collapse" data-bs-target="#<%= [opts[:fourth_sub_menu], sub2.id].join %>">
<%= link_to sub2.name, index_url(sub2.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub3 clickable-link" %>
</button>
<% else %>
<%= link_to sub2.name, index_url(sub2.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub3 clickable-link" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= [opts[:fourth_sub_menu], sub2.id].join %>" data-bs-parent="#thirdLevelSubMenu">
<div class="accordion-body pb-0 pe-0 pt-0">
<% sub2.children.order(name: :asc).each do |sub3| %>
<div class="accordion accordion-flush ps-20" id="fourthLevelSubMenu">
<div class="accordion-item bg-transparent">
<div class="accordion-header">
<% if sub3.children.present? %>
<button class="accordion-button collapsed bg-transparent" type="button" data-bs-toggle="collapse" data-bs-target="#<%= [opts[:fifth_sub_menu], sub3.id].join %>">
<%= link_to sub3.name, index_url(sub3.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub4 clickable-link" %>
</button>
<% else%>
<%= link_to sub3.name, index_url(sub3.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub4 clickable-link" %>
<% end %>
</div>
<div class="accordion-collapse collapse" id="<%= [opts[:fifth_sub_menu], sub3.id].join %>" data-bs-parent="#fourthLevelSubMenu">
<div class="accordion-body pb-0 pe-0 pt-0">
<% sub3.children.order(name: :asc).each do |sub4| %>
<div class="accordion-item bg-transparent">
<div class="accordion-header">
<%= link_to sub4.name, index_url(sub4.id), class: "accordion-link text-white text-decoration-none text-dark d-block sub5 clickable-link" %>
</div>
</div>
<% end if sub3.children.present? %>
</div>
</div>
</div>
</div>
<% end if sub2.children.present? %>
</div>
</div>
</div>
</div>
<% end if sub1.children.present? %>
</div>
</div>
</div>
</div>
<% end if root.children.present? %>
</div>
</div>
<% end %>
</div>
</div>
<% end if Cdao::Subject.roots.present? %>
</div>
</div>

48
app/controllers/api/doctrine/annotations_controller.rb

@ -1,10 +1,22 @@
module Api
module Doctrine
class AnnotationsController < ::Api::BaseController
include AnnotationSearch
load_and_authorize_resource :doctrine, class: "Doctrine"
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
def index
search = annotation_search(search_params)
@annotations = search.results
respond_with @annotations
end
def search
search = annotation_search(search_params)
@annotations = search.results
respond_with @annotations
end
@ -14,14 +26,24 @@ module Api
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
document_id = attrs.delete(:document_id)
document_ids = params[:document_ids].split(",")
@annotation = @doctrine.annotations.new(attrs)
if document_id.present?
@annotation.document = Cdao::Document.find(document_id)
end
if document_ids.present?
@documents = Cdao::Document.where(id: document_ids)
end
if @annotation.save
@annotation.subject_ids = subject_ids if subject_ids.present?
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
respond_with @annotation
@annotation.index!
else
render errors: @annotation.errors, status: 422
end
@ -29,12 +51,24 @@ module Api
def update
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
document_id = attrs.delete(:document_id)
document_ids = params[:document_ids].split(",")
if document_ids.present?
@documents = Cdao::Document.where(id: document_ids)
end
attrs[:document] = Cdao::Document.find(document_id) if document_id.present?
if @annotation.update(attrs)
@annotation.subject_ids = subject_ids if subject_ids.present?
@annotation.annotation_documents.each do |annotation_document|
@annotation.remove_document(annotation_document.document)
end
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
respond_with @annotation
@annotation.index!
else
render errors: @annotation.errors, status: 422
end
@ -49,7 +83,11 @@ module Api
private
def resource_params
params.permit(:content, subject_ids: [])
params.permit(:document_id, :content, :phil_rep, :editor_notes, :rank, annomark_ids: [])
end
def search_params
params.permit(:doctrine_id, :document_id, :phil_rep, :q, :page, :per_page)
end
end
end

63
app/controllers/api/doctrines_controller.rb

@ -3,8 +3,7 @@ module Api
class DoctrinesController < BaseController
include DoctrineSearch
load_and_authorize_resource :doctrine, class: "Doctrine", only: %i[show]
authorize_resource :doctrine, class: "Doctrine", only: %i[index]
load_and_authorize_resource :doctrine, class: "Doctrine"
def index
search = doctrine_search(search_params)
@ -18,12 +17,70 @@ module Api
respond_with @doctrine
end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
jurisprudence_ids = attrs.delete(:jurisprudence_ids)
@doctrine = ::Doctrine.new(attrs)
if @doctrine.save
@doctrine.subject_ids = subject_ids if subject_ids.present?
jurisprudence_ids.each do |jurisprudence_id|
doctrine_jurisprudence = @doctrine.doctrine_jurisprudences.create(jurisprudence_id: jurisprudence_id)
doctrine_jurisprudence.jurisprudence.index! if doctrine_jurisprudence.persisted?
end
respond_with @doctrine
@doctrine.index!
else
render errors: @doctrine.errors, status: 422
end
end
def update
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
if @doctrine.update(attrs)
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
@doctrine.index!
else
render errors: @doctrine.errors, status: 422
end
end
def destroy
@doctrine.destroy
respond_with @doctrine
end
def suggested_contents
@doctrines = []
search = doctrine_search(search_params.to_unsafe_h.merge({ is_grouped_by_content: true, per_page: 100000 }))
search.group(:content).groups.each do |group_by_content|
group_by_content.results.each do |result|
@doctrines << result
end
end
respond_with @doctrines
end
private
def resource_params
params.permit(:content, :headnote, jurisprudence_ids: [], subject_ids: [])
end
def search_params
params.permit(:created_at, :q, :page, :per_page,
exclude_ids: [], subject_ids: [], user_ids: [])
end
end
end

7
app/controllers/api/documents_controller.rb

@ -1,7 +1,6 @@
module Api
class DocumentsController < BaseController
load_and_authorize_resource :document, class: "Cdao::Document", only: %i[show]
authorize_resource :document, class: "Cdao::Document", only: %i[index]
def index
search = document_search(search_params)
@ -21,10 +20,10 @@ module Api
fulltext_fields = %i[reference_number title short_title].freeze
search = Cdao::Document.search do
fulltext search_params[:q], fields: fulltext_fields, query_phrase_slop: 1, minimum_match: 1 if search_params[:q].present?
fulltext search_params[:q], fields: fulltext_fields, query_phrase_slop: 1 if search_params[:q].present?
fulltext_fields.each do |field|
fulltext search_params[field], fields: [field], query_phrase_slop: 1, minimum_match: 1 if search_params[field].present?
fulltext search_params[field], fields: [field], query_phrase_slop: 1 if search_params[field].present?
end
with(:year, search_params[:year].to_i) if search_params[:year].present?
@ -47,7 +46,7 @@ module Api
def search_params
params.permit(:reference_number, :title, :short_title, :year, :citation_finder,
:q, :page, :per_page,
exclude_ids: [])
exclude_ids: [], sort_by: %i[search_year reference_number search_doc_date])
end
end
end

40
app/controllers/api/jurisprudence/doctrines_controller.rb

@ -11,46 +11,6 @@ module Api
def show
respond_with @doctrine
end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
@doctrine = @jurisprudence.doctrines.new(attrs)
if @doctrine.save
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
else
render errors: @doctrine.errors, status: 422
end
end
def update
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
if @doctrine.update(attrs)
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
else
render errors: @doctrine.errors, status: 422
end
end
def destroy
@doctrine.destroy
respond_with @doctrine
end
private
def resource_params
params.permit(:content, subject_ids: [])
end
end
end
end

4
app/controllers/api/jurisprudences_controller.rb

@ -19,7 +19,9 @@ module Api
def years
authorize! :index, Cdao::Jurisprudence
@years = (1901..Time.zone.today.year).entries.reverse
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :asc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
@years = (start_year..end_year).entries.reverse
respond_with @years
end

2
app/controllers/api/subjects_controller.rb

@ -14,7 +14,7 @@ module Api
private
def search_params
params.permit(:q, :name, :parent_id, :state, :doctrine_ids, :page, :per_page, exclude_ids: [])
params.permit(:q, :name, :parent_id, :state, :doctrine_ids, :is_root, :page, :per_page, exclude_ids: [])
end
end
end

21
app/controllers/concerns/annotation_search.rb

@ -0,0 +1,21 @@
module AnnotationSearch
def annotation_search(search_params)
fulltext_fields = %i[phil_rep].freeze
search = ::Annotation.search do
fulltext search_params[:q], fields: fulltext_fields if search_params[:q].present?
%i[doctrine_id document_id].each do |field|
with field, search_params[field] if search_params[field].present?
end
order_by :library_rank, :asc
order_by :search_year, :desc
order_by :search_doc_date, :desc
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end
search
end
end

33
app/controllers/concerns/doctrine_search.rb

@ -5,16 +5,45 @@ module DoctrineSearch
search = ::Doctrine.search do
fulltext search_params[:q], fields: fulltext_fields if search_params[:q].present?
with(:subject_ids).any_of(search_params[:subject_ids]) if search_params[:subject_ids].present?
with(:subject_ids).any_of(search_params[:subject_ids].map(&:to_i)) if search_params[:subject_ids].present?
with(:user_ids).any_of(search_params[:user_ids]) if search_params[:user_ids].present?
with(:user_ids).any_of(search_params[:user_ids].map(&:to_i)) if search_params[:user_ids].present?
with(:jurisprudence_id, search_params[:jurisprudence_id]) if search_params[:jurisprudence_id].present?
%i[headnote content].each do |field|
with(field, search_params[field]) if search_params[field].present?
end
if search_params[:created_at].present?
with(:created_at).between(Date.parse(search_params[:created_at])..Time.zone.today.to_date)
end
if search_params[:created_at_start].present? && search_params[:created_at_end].blank?
with(:created_at).between(Date.parse(search_params[:created_at_start])..Time.zone.today.to_date)
end
if search_params[:created_at_start].present? && search_params[:created_at_end].present?
with(:created_at).between(Date.parse(search_params[:created_at_start])..Date.parse(search_params[:created_at_end]))
end
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
if search_params[:is_grouped_by_headnote].to_s.eql?("true")
group :headnote
end
if search_params[:is_grouped_by_content].to_s.eql?("true")
group :content
end
if search_params[:is_grouped_by_juris_id].to_s.eql?("true")
group :jurisprudence_id
end
order_by :search_year, :desc
order_by :search_doc_date, :desc
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end

70
app/controllers/concerns/document_search.rb

@ -0,0 +1,70 @@
module DocumentSearch
def document_search(search_params)
search_params.each { |k, v| params[k] = v.gsub(/“|”/, '"') if v.is_a?(String) }
fulltext_fields = %i[reference_number title short_title].freeze
search = Cdao::Document.search do
fulltext search_params[:q], fields: fulltext_fields, query_phrase_slop: 1 if search_params[:q].present?
fulltext_fields.each do |field|
fulltext search_params[field], fields: [field], query_phrase_slop: 1 if search_params[field].present?
end
with(:year, search_params[:year].to_i) if search_params[:year].present?
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
if search_params[:sort_by].blank?
order_by :search_year, :desc
order_by :search_doc_date, :desc
order_by :reference_number, :desc
end
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end
search
end
def sanitize_citer_finder_param(citation_finder_param)
citation_finder = []
params_vol = []
params_type = []
params_page = []
params[:citation_finder].scan(/\b((\d+\-?\w?)\s(SCRA|PhilRep|Phil|\S+)\.?,?\s?([-,\d\s]+)?)\b/i).map do |cit_fin|
params_vol << cit_fin[1].gsub(/\s+/, "").gsub(/\A0*/, "")
params_type.concat(case cit_fin[2]
when /SCRA/i
["SCRA"]
when /(PhilRep|Phil)\.?,?/i
["Phil"]
else
[]
end
)
cit_fin[3].scan(/\d+-?\d*/).each do |page|
if page.match?(/-/)
page_range = []
page.scan(/\d+?\d*/).each do |each_page|
page_range << each_page.to_i
end
params_page.concat((page_range[0]..page_range[1]).to_a)
else
params_page << page.to_i if params_page.index(page.to_i).blank?
end
end if cit_fin[3].present?
end
params_type.compact.each do |type|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type}" if params_page.blank?
params_page.compact.uniq.each do |page|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type} #{page}"
end
end
return [] if citation_finder.blank?
citation_finder
end
end

64
app/controllers/concerns/jurisprudence_search.rb

@ -1,30 +1,78 @@
module JurisprudenceSearch
def jurisprudence_search(search_params)
search_params.each { |k, v| params[k] = v.gsub(/“|”/, '"') if v.is_a?(String) }
fulltext_fields = %i[reference_number title short_title].freeze
search = Cdao::Jurisprudence.search do
fulltext search_params[:q], fields: fulltext_fields if search_params[:q].present?
fulltext_fields.each do |field|
fulltext search_params[field], fields: [field] if search_params[field].present?
%i[reference_number title short_title].each do |field|
fulltext search_params[field], fields: [field], query_phrase_slop: 1 if search_params[field].present?
end
with(:year, search_params[:year].to_i) if search_params[:year].present?
if search_params[:year_start].present? && search_params[:year_end].present?
with(:year).between(search_params[:year_start].to_i..search_params[:year_start].to_i)
end
if search_params[:year_start].present? && search_params[:year_end].blank?
with(:year, search_params[:year_start].to_i)
end
with(:subject_ids).any_of(search_params[:subject_ids].split(",").map(&:strip).map(&:to_i)) if search_params[:subject_ids].present?
with(:citation_finders_names).any_of(search_params[:citation_finder]) if search_params[:citation_finder].present?
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
with(:is_only_in_premium_libraries, false)
order_by :doc_date, :desc
order_by :year, :desc
if search_params[:sort_by].blank?
order_by :search_year, :desc
order_by :search_doc_date, :desc
order_by :reference_number, :desc
end
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end
search
end
def sanitize_citer_finder_param(citation_finder_param)
citation_finder = []
params_vol = []
params_type = []
params_page = []
params[:citation_finder].scan(/\b((\d+\-?\w?)\s(SCRA|PhilRep|Phil|\S+)\.?,?\s?([-,\d\s]+)?)\b/i).map do |cit_fin|
params_vol << cit_fin[1].gsub(/\s+/, "").gsub(/\A0*/, "")
params_type.concat(case cit_fin[2]
when /SCRA/i
["SCRA"]
when /(PhilRep|Phil)\.?,?/i
["Phil"]
else
[]
end
)
cit_fin[3].scan(/\d+-?\d*/).each do |page|
if page.match?(/-/)
page_range = []
page.scan(/\d+?\d*/).each do |each_page|
page_range << each_page.to_i
end
params_page.concat((page_range[0]..page_range[1]).to_a)
else
params_page << page.to_i if params_page.index(page.to_i).blank?
end
end if cit_fin[3].present?
end
params_type.compact.each do |type|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type}" if params_page.blank?
params_page.compact.uniq.each do |page|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type} #{page}"
end
end
return [] if citation_finder.blank?
citation_finder
end
end

2
app/controllers/concerns/subject_search.rb

@ -11,7 +11,7 @@ module SubjectSearch
with :parent_id, search_params[:parent_id].to_i if search_params[:parent_id].present?
without :parent_id if search_params[:is_root].present? && search_params[:is_root].to_s.eql?("true")
with :parent_id, nil if search_params[:is_root].present? && search_params[:is_root].to_s.eql?("true")
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?

7
app/controllers/decisions_controller.rb

@ -9,7 +9,10 @@ class DecisionsController < ApplicationController
search = jurisprudence_search(search_params)
@jurisprudences = search.results
@years = (1901..Time.zone.today.year).entries.reverse
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :asc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
@years = (start_year..end_year).entries.reverse
respond_to do |format|
format.html
@ -20,6 +23,6 @@ class DecisionsController < ApplicationController
def search_params
params.permit(:reference_number, :title, :short_title, :q, :page, :per_page,
:subject_ids)
:subject_ids, sort_by: %i[search_year reference_number search_doc_date])
end
end

17
app/controllers/doctrine/annotations_controller.rb

@ -2,6 +2,10 @@ class Doctrine::AnnotationsController < ApplicationController
load_and_authorize_resource :doctrine, class: "Doctrine"
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
def new; end
def edit; end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
document_id = attrs.delete(:document_id)
@ -21,10 +25,10 @@ class Doctrine::AnnotationsController < ApplicationController
if @annotation.save
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
notice: "Doctrine Annotation was successfully created." }
else
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine) }
format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine) }
end
end
end
@ -48,22 +52,21 @@ class Doctrine::AnnotationsController < ApplicationController
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
notice: "Doctrine Annotation was successfully updated." }
else
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine) }
format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine) }
end
end
end
def destroy
document_id = @doctrine.document_id
respond_to do |format|
if @annotation.destroy
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
notice: "Doctrine Annotation was successfully destroyed." }
else
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine),
format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
alert: @annotation.errors.full_messages }
end
end

54
app/controllers/doctrines_controller.rb

@ -1,8 +1,13 @@
class DoctrinesController < ApplicationController
include DoctrineSearch
include AnnotationSearch
load_and_authorize_resource :doctrine, class: "Doctrine"
def new; end
def edit; end
def index
@search = doctrine_search(search_params)
@doctrines = @search.results
@ -14,18 +19,61 @@ class DoctrinesController < ApplicationController
def search
@search = doctrine_search(search_params)
@doctrines = @search.results
@search_results = @search.results
respond_to do |format|
format.html
end
end
def show; end
def show
@jurisprudence = @doctrine.doctrine_jurisprudences.present? ? @doctrine.doctrine_jurisprudences.first.jurisprudence : nil
search = annotation_search({ doctrine_id: @doctrine.id })
@annotations = search.results
end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
@doctrine = Doctrine.new(attrs)
if @doctrine.save
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
else
render errors: @doctrine.errors, status: 422
end
end
def update
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
if @doctrine.update(attrs)
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
else
render errors: @doctrine.errors, status: 422
end
end
def destroy
@doctrine.destroy
respond_with @doctrine
end
private
def resource_params
params.permit(:content, :headnote, jurisprudence_ids: [], subject_ids: [])
end
def search_params
params.permit(subject_ids: [])
params.permit(:page, :per_page, jurisprudence_ids: [], subject_ids: [])
end
end

7
app/controllers/document/doctrines_controller.rb

@ -1,7 +1,12 @@
class Document::DoctrinesController < ApplicationController
include AnnotationSearch
load_and_authorize_resource :document, class: "Cdao::Jurisprudence"
load_and_authorize_resource :doctrine, class: "Doctrine", through: :document
def show; end
def show
search = annotation_search({ doctrine_id: @doctrine.id })
@annotations = search.results
end
end

16
app/controllers/documents_controller.rb

@ -1,7 +1,9 @@
class DocumentsController < ApplicationController
include JurisprudenceSearch
include DoctrineSearch
load_and_authorize_resource :document, class: "Cdao::Jurisprudence"
load_and_authorize_resource :document, class: "Cdao::Jurisprudence", only: %i[index search]
load_and_authorize_resource :document, class: "Cdao::Document", only: %i[show]
def index
@search_params = search_params
@ -15,11 +17,13 @@ class DocumentsController < ApplicationController
end
def show
@subjects = Cdao::Subject.all
@doctrines = @document.doctrines
if @document.library.document_type.eql?(Cdao::Library.first.document_type)
@jurisprudence = Cdao::Jurisprudence.find(@document.doc_id)
where = { enabled: true, state: "published" }
@cited_in_documents = @document.class.citing_docs_of(@document, where)
@cited_in_documents = @jurisprudence.class.citing_docs_of(@jurisprudence, where)
@paginated_cited_in_documents = Kaminari.paginate_array(@cited_in_documents, total_count: @cited_in_documents.count).page(params[:page]).per(20)
end
# @cross_ref_documents = @document.class.cited_docs_of(document, where)
end
@ -33,8 +37,8 @@ class DocumentsController < ApplicationController
private
def search_params
params.permit(:reference_number, :title, :short_title,
:year, :citation_finder, :subject_ids,
params.permit(:reference_number, :title, :short_title, :ponente,
:year_start, :year_end, :citation_finder, :subject_ids,
:q, :page, :per_page)
end
end

52
app/controllers/jurisprudence/doctrines_controller.rb

@ -1,52 +0,0 @@
class Jurisprudence::DoctrinesController < ApplicationController
load_and_authorize_resource :jurisprudence, class: "Cdao::Jurisprudence"
load_and_authorize_resource :doctrine, class: "Doctrine", through: :jurisprudence
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
@doctrine = @jurisprudence.doctrines.new(attrs)
respond_to do |format|
if @doctrine.save
@doctrine.subject_ids = subject_ids if subject_ids.present?
format.html { redirect_to document_doctrine_path(@jurisprudence, @doctrine), notice: "Doctrine was successfully created." }
else
format.html { redirect_to document_doctrine_path(@jurisprudence) }
end
end
end
def update
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
respond_to do |format|
if @doctrine.update(attrs)
@doctrine.subject_ids = subject_ids if subject_ids.present?
format.html { redirect_to document_doctrine_path(@jurisprudence, @doctrine), notice: "Doctrine was successfully updated." }
else
format.html { redirect_to document_doctrine_path(@jurisprudence) }
end
end
end
def destroy
respond_to do |format|
if @doctrine.destroy
format.html { redirect_to document_path(@jurisprudence), notice: "Doctrine was successfully destroyed." }
else
format.html { redirect_to document_path(@jurisprudence), alert: @doctrine.errors.full_messages }
end
end
end
private
def resource_params
params.permit(:content, subject_ids: [])
end
end

17
app/controllers/reports_controller.rb

@ -0,0 +1,17 @@
class ReportsController < ApplicationController
include DoctrineSearch
def index
authorize! :display, Doctrine
search = doctrine_search(search_params)
@results = search.results
@users = User.all
end
private
def search_params
params.permit(:created_at, :created_at_start, :created_at_end, :q, :page, :per_page, exclude_ids: [], subject_ids: [], user_ids: [])
end
end

83
app/javascript/controllers/annotations_controller.js

@ -1,32 +1,31 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids",
"annomark_ids", "phil_rep", "editor_notes"]
static targets = ["q", "document_ids", "annomark_ids", "phil_rep", "editor_notes"]
connect () {
super.connect()
}
searchDocument () {
var $this = this
$.get("/api/documents.json", { q: $this.qTarget.value }, function (data, status) {
if (status === "success") {
$this.stimulate("AnnotationReflex#render_document_search_results", data)
searchDocuments () {
this.stimulate("AnnotationReflex#render_document_search_results", { q: this.qTarget.value, page: 1 })
}
});
paginateDocuments () {
this.stimulate("AnnotationReflex#render_document_search_results", { q: this.element.dataset["q"], page: this.element.dataset["page"] })
}
renderForm () {
var $this = this, annotation_id = $this.element.dataset["annotationId"], doctrine_id = $this.element.dataset["doctrineId"],
document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#annotationModal")
$modal.find("#current_document_id").val($this.element.dataset["currentDocumentId"])
if(annotation_id !== null && annotation_id !== undefined && annotation_id !== "") {
$modal.find(".modal-title").text("Edit Annotation")
$.get("/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id + ".json", {}, function(result, status) {
$modal.find("#annotation_id").val(annotation_id)
$modal.find("#doctrine_id").val(doctrine_id)
$modal.find("#document_id").val(result.citing_document_ids)
$modal.find("#document_ids").val(result.document_id)
$modal.find("#document_id").val(result.document_id)
$modal.find("#document_ids").val(result.citing_document_ids)
$modal.find("#phil_rep").val(result.phil_rep)
$modal.find("#document_title").val($this.element.dataset["documentTitle"])
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(result.annomark_ids)
@ -45,10 +44,10 @@ export default class extends ApplicationController {
}
}
addCitingDocument () {
addAnnotatedDocument () {
var document_id = "", document_ref_no = "", document_date = "", document_title = "",
$modal = $("#annotationModal"), $doc_title = $modal.find("#document_title"),
$citing_document_ids = $modal.find("#document_ids")
$form = $("#annotationForm"), $doc_title = $form.find("trix-editor[placeholder='Document Title']"),
$citing_document_ids = $form.find("#document_ids")
document_id = this.element.dataset["documentId"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
@ -69,19 +68,65 @@ export default class extends ApplicationController {
}
save () {
var $this = this, $modal = $("#annotationModal"), annotation_id = $this.annotation_idTarget.value, doctrine_id = $this.doctrine_idTarget.value
const params = { annomark_ids: $modal.find("select[name='annomark_ids[]']").val(), document_id: $this.document_idTarget.value,
var $this = this, $form = $("#annotationForm"), annotation_id = $this.element.dataset["annotationId"],
jurisprudence_id = $this.element.dataset["jurisprudenceId"], doctrine_id = $this.element.dataset["doctrineId"]
const params = { annomark_ids: $form.find("select[name='annomark_ids[]']").val(), document_id: $this.element.dataset["documentId"],
document_ids: $this.document_idsTarget.value || "", phil_rep: $this.phil_repTarget.value || "",
editor_notes: $this.editor_notesTarget.value || "" }
editor_notes: $this.editor_notesTarget.value || "", content: $form.find("input[name='content']").val() }
if (annotation_id !== null && annotation_id !== undefined && annotation_id !== "") {
$.ajax({
url: "/doctrines/" + doctrine_id + "/annotations/" + annotation_id,
url: "/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id,
type: 'PUT',
data: params
data: params,
success: function() {
$(".btn-close-x").trigger("click")
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
},
error: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
}
})
} else {
$.post("/doctrines/" + doctrine_id + "/annotations", params)
$.post("/api/doctrines/" + doctrine_id + "/annotations", params, function(result, status) {
if(status === "success") {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
} else {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
}
})
}
}
delete(ev) {
var $this = this, doctrine_id = $this.element.dataset["doctrineId"], annotation_id = this.element.dataset["annotationId"],
jurisprudence_id = $this.element.dataset["jurisprudenceId"]
ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?")
if (contrim_alert) {
$.ajax({
url: "/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id,
type: 'DELETE',
success: function() {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" );
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
}
})
}
}
paginate () {
this.stimulate("AnnotationReflex#render_annotations_views", { doctrine_id: this.element.dataset["doctrineId"], page: this.element.dataset["page"] })
}
}

24
app/javascript/controllers/application_controller.js

@ -21,9 +21,33 @@ import Selectize from "selectize";
*/
export default class extends Controller {
connect () {
$(".reset-document-advanced-search").on("click", function (ev) {
ev.preventDefault()
var $advanced_search_box = $(".advanced-search-box")
$.each($advanced_search_box.find("input[type='text']"), function(_, el) {
$(el).val("")
})
$.each($advanced_search_box.find("select"), function(_, el) {
$(el).val("")
})
})
StimulusReflex.register(this)
}
openLink ($event) {
$event.preventDefault()
window.location.href = this.element.dataset['href']
}
openLinkToNewTab ($event) {
$event.preventDefault()
window.open(this.element.dataset['href'])
}
/* Application-wide lifecycle methods
*
* Use these methods to handle lifecycle concerns for the entire application.

206
app/javascript/controllers/doctrines_controller.js

@ -1,6 +1,7 @@
import ApplicationController from './application_controller'
var annotations_attributes = []
export default class extends ApplicationController {
static targets = ["input", "document_id", "doctrine_id", "content"]
static targets = ["input", "q", "document_id", "doctrine_id", "headnote", "content"]
connect () {
super.connect()
@ -11,12 +12,11 @@ export default class extends ApplicationController {
$modal = $("#doctrineModal"), $subject_ids_el = $modal.find(".subject-ids-selectize"),
$subject_ids_selectize = $subject_ids_el[0].selectize
console.log(this.element.dataset)
$modal.find("#document_id").val(document_id)
if (doctrine_id !== null && doctrine_id !== undefined && doctrine_id !== "") {
$modal.find("#doctine_content_suggestions_div").hide()
$.get("/api/doctrines/" + doctrine_id + ".json", {}, function (doctrine, status) {
$modal.find("#document_id").val(doctrine.document_id)
$modal.find("#doctrine_id").val(doctrine.id)
if (status === "success") {
$.get("/api/subjects.json?doctrine_ids=" + doctrine.id, { per_page: 100 }, function (subjects, status) {
@ -26,11 +26,14 @@ export default class extends ApplicationController {
})
$subject_ids_selectize.refreshOptions()
$subject_ids_selectize.setValue(doctrine.subject_ids)
$subject_ids_selectize.setValue(doctrine.subject_ids, true)
$subject_ids_selectize.blur()
$subject_ids_selectize.close()
}
});
$modal.find(".trix-content").val(doctrine.content)
$modal.find("#headnote").val(doctrine.headnote)
}
})
@ -41,22 +44,205 @@ export default class extends ApplicationController {
$modal.find(".modal-title").text("New Doctrine")
$modal.find(".trix-content").val("")
$subject_ids_selectize.setValue([])
$modal.find("#document_id").val(document_id)
$modal.find("#doctrine_id").val('')
$modal.find("#headnote").val('')
}
}
save () {
var $modal = $("#doctrineModal"), document_id = this.document_idTarget.value, doctrine_id = this.doctrine_idTarget.value
const params = { subject_ids: $modal.find("select[name='subject_ids[]']").val(), content: this.contentTarget.value }
var $this = this, $form = $("#doctrineForm"), document_id = $this.document_idTarget.value, doctrine_id = $this.doctrine_idTarget.value
var params = { subject_ids: $form.find("select[name='subject_ids[]']").val(), headnote: $this.headnoteTarget.value,
content: $this.contentTarget.value }
if (!params.subject_ids.length) {
$form.find("#subjects-blank-message").show()
}
if (!params.headnote.length) {
$form.find("#headnote-blank-message").show()
}
if (!params.content.length) {
$form.find("#content-blank-message").show()
}
if (params.subject_ids.length && params.headnote.length && params.content.length) {
if (doctrine_id !== null && doctrine_id !== undefined && doctrine_id !== "") {
$.ajax({
url: "/jurisprudences/" + document_id + "/doctrines/" + doctrine_id,
url: "/api/doctrines/" + doctrine_id,
type: 'PUT',
data: params
data: params,
success: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id
},
error: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
$('.toast').fadeOut(5000);
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
}
})
} else {
$.post("/api/doctrines", $.extend({ jurisprudence_ids: [document_id] }, params), function(doctrine, status) {
if(status === 'success') {
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Doctrine was successfully saved</b></span>" );
$('.toast').fadeOut(5000);
if (annotations_attributes.length > 0) {
$.each(annotations_attributes, function(index, annotation) {
$.post("/api/doctrines/" + doctrine.id + "/annotations", annotation, function(result, status) {
if(status === 'success') {
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Case Lists was successfully saved</b></span>" );
$('.toast').fadeOut(5000);
if (index === annotations_attributes.length - 1) {
$(window).delay(5000).queue(function() {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id
})
}
}
})
})
} else {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id
}
} else {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
$('.toast').fadeOut(5000);
}
})
}
}
}
delete(ev) {
var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"]
ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?")
if (contrim_alert) {
$.ajax({
url: "/api/doctrines/" + doctrine_id,
type: 'DELETE',
success: function() {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id
},
error: function () {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
$('.toast').fadeOut(5000);
}
})
}
}
searchCitingDocuments () {
this.stimulate("DoctrinesReflex#render_citing_documents_search_results", { q: this.qTarget.value, page: 1 })
}
paginateCitingDocuments () {
this.stimulate("AnnotationReflex#render_citing_documents_search_results", { q: this.element.dataset["q"], page: this.element.dataset["page"] })
}
addCitingDocument () {
var document_id = "", document_ref_no = "", document_date = "", document_title = "",
$modal = $("#annotationModal"), $doc_title = $modal.find("trix-editor[placeholder='Document Title']"),
$citing_document_ids = $modal.find("#document_ids")
document_id = this.element.dataset["documentId"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
document_date = this.element.dataset["documentDate"]
document_title = this.element.dataset["documentTitle"]
var document_ids = []
if ($citing_document_ids.val() !== null && $citing_document_ids.val() !== undefined && $citing_document_ids.val() !== "") {
document_ids = $citing_document_ids.val().split(",")
}
document_ids.push(document_id)
$citing_document_ids.val(document_ids.join(","))
var doc_title = $doc_title.val()
$doc_title.val(doc_title + " citing " + [document_title, document_ref_no, document_date].join(", "))
}
removeAnnotation () {
var index = this.element.dataset["annotationsAttributesIndex"]
const contrim_alert = confirm("Are you sure that you want to remove this Case List?")
if (contrim_alert) {
annotations_attributes.splice(index, 1)
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Case List is successfully removed.</b></span>" );
$('.toast').fadeOut(5000)
this.stimulate("DoctrinesReflex#render_doctrine_form_annotations_view", annotations_attributes)
}
}
saveAnnotation () {
var $modal = $("#annotationModal"), annotaitons_attributes_index = $modal.find("#annotaitons_attributes_index").val()
var params = { document_id: $modal.find("#document_id").val(), document_ids: $modal.find("#document_ids").val().split(","),
content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(),
editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() }
if (annotaitons_attributes_index.length > 0) {
annotations_attributes.splice(annotaitons_attributes_index, 1, params)
$( ".toast-body" ).html( "<span><b>Case List is successfully updated.</b></span>" );
} else {
$.post("/jurisprudences/" + document_id + "/doctrines", params)
annotations_attributes.push(params)
$( ".toast-body" ).html( "<span><b>Case List is successfully added.</b></span>" );
}
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$('.toast').fadeOut(5000);
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue([])
this.stimulate("DoctrinesReflex#render_doctrine_form_annotations_view", annotations_attributes)
this.stimulate("DoctrinesReflex#render_default_citing_documents")
this.stimulate("DoctrinesReflex#render_default_case_lists")
}
newAnnotation () {
var document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#annotationModal")
$modal.find(".modal-title").text("New Annotation")
document_title = this.element.dataset["documentTitle"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
document_date_or_year = this.element.dataset["documentDateOrYear"]
$modal.find("select[name='annomark_ids[]']").val([])
$modal.find("#doctrine_id").val(null)
$modal.find("trix-editor[placeholder='Document Title']").val([document_title, document_ref_no, document_date_or_year].join(", "))
$modal.find("#document_id").val(this.element.dataset["documentId"])
$modal.find("#phil_rep").val(this.element.dataset["documentPhilRep"])
}
editAnnotation () {
var $modal = $("#annotationModal"), annotations_attributes_index = this.element.dataset["annotationsAttributesIndex"],
annotation = annotations_attributes[annotations_attributes_index]
$modal.find(".modal-title").text("Edit Annotation")
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(annotation.annomark_ids)
$modal.find("trix-editor[placeholder='Document Title']").val(annotation.content)
$modal.find("#document_id").val(annotation.document_id)
$modal.find("#annotaitons_attributes_index")[0].selectize.setValue(annotations_attributes_index)
if (annotation.document_ids.length) {
$modal.find("#document_ids").val(annotation.document_ids.join(","))
}
$modal.find("#phil_rep").val(annotation.phil_rep)
}
}

26
app/javascript/controllers/document_controller.js

@ -1,19 +1,33 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
static targets = ["input"]
static targets = ["input", "citation_finder"]
connect () {
super.connect()
}
search () {
var $this = this
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 },
this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
}
$.get("/api/documents.json", { q: $this.inputTarget.value }, function (data, status) {
if (status === "success") {
$this.stimulate("DocumentReflex#render_index_table", data, $this.element.dataset["documentId"], $this.element.dataset["doctrineId"])
searchDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 })
}
});
paginateDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
page: this.element.dataset["page"] })
}
paginate () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
page: this.element.dataset["page"] },
this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
}
loadYears () {

17
app/javascript/controllers/reports_controller.js

@ -0,0 +1,17 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
static targets = ["q", "headnote", "date_created"]
connect () {
super.connect()
}
search () {
var $search_box = $('.advanced-search-box'),
search_params = { q: this.qTarget.value, headnote: this.headnoteTarget.value,
subject_ids: $search_box.find("select[name='subject_ids[]']").val(),
user_ids: $search_box.find("select[name='user_ids[]']").val() }
this.stimulate("ReportsReflex#render_search_results", search_params)
}
}

29
app/javascript/controllers/selectize_controller.js

@ -18,8 +18,9 @@ export default class extends ApplicationController {
$(".default-selectize").selectize(default_opts);
var $doctrine_content = $("#doctrineModal").find("input[name='content']");
var $trix_content = $("#doctrineModal").find(".trix-content");
var $doctrine_form = $("#doctrineForm")
var $doctrine_content = $doctrine_form.find("input[name='content']");
var $trix_content = $doctrine_form.find("trix-editor[placeholder='Doctrine Content']");
var doctrine_content_suggestions_opts = {
onChange: function (value) {
@ -30,6 +31,7 @@ export default class extends ApplicationController {
$.get("/api/doctrines/" + value + ".json", {}, function (doctrine, status) {
if (status === "success") {
$doctrine_content.val(doctrine.content);
$doctrine_form.find("input[name='headnote']").val(doctrine.headnote)
$trix_content.val(doctrine.content);
}
});
@ -47,12 +49,12 @@ export default class extends ApplicationController {
},
onChange: function (value) {
var selectize_options = []
var $selectize = $("#doctrineModal").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
var $selectize = $("#doctrineForm").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
if (value.length === 0) {
if ($selectize.length) $selectize[0].selectize.clearOptions();
} else {
$.get("/api/doctrines.json", { subject_ids: value }, function(data, status) {
$.get("/api/doctrines/suggested_contents.json", { subject_ids: value }, function(data, status) {
if (status === "success") {
$.each(data, function (i, doctrine) {
selectize_options.push({ id: doctrine.id, value: doctrine.content, text: doctrine.plain_content });
@ -69,13 +71,28 @@ export default class extends ApplicationController {
var $subject_ids_selectize = $(".subject-ids-selectize").selectize($.extend(subject_ids_opts, default_opts));
var subjects_selectize_opts = {
load: function (query, callback) {
$.get("/api/subjects.json", { q: query, per_page: 100 }, function (data, status) {
if (status === 'success') {
callback(data);
}
})
}
}
var $subjects_selectize = $(".subjects-selectize").selectize($.extend(subjects_selectize_opts, default_opts))
$.get("/api/subjects.json", { per_page: 100 }, function (results, status) {
if (status === 'success') {
$.each(results, function (i, result) {
$subject_ids_selectize[0].selectize.addOption(result);
if ($subject_ids_selectize.length) $subject_ids_selectize[0].selectize.addOption(result, true);
if ($subjects_selectize.length) $subjects_selectize[0].selectize.addOption(result, true);
})
$subject_ids_selectize[0].selectize.refreshOptions();
//this code will be autoFocus on the first selectize
// if ($subject_ids_selectize.length) $subject_ids_selectize[0].selectize.refreshOptions();
// if ($subjects_selectize.length) $subjects_selectize[0].selectize.refreshOptions();
}
});

52
app/javascript/controllers/subjects_controller.js

@ -4,19 +4,61 @@ export default class extends ApplicationController {
super.connect()
}
renderSidenavAccordion () {
var parent_id = this.element.dataset["subjectParentId"], $this = this, params = {}
loadSubjectsAccordion () {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { parent_accordion_id: $this.element.dataset["accordionId"], accordionTarget: $this.element.dataset["accordionTarget"],
accordionFor: $this.element.dataset["accordionFor"] }
if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id
} else {
params.is_root_only = true
params.is_root = true
}
$.get("/api/subjects.json", params, function (results, status) {
if ($(opts.accordionTarget).find(".accordion-flush").length === 0) {
$.get("/api/subjects.json", params, function (search_results, status) {
if (status === "success") {
$this.stimulate("SubjectsReflex#render_sidenav_accordion", results)
$this.stimulate("SubjectsReflex#render_subjects_accordion", search_results, opts)
}
})
}
}
loadSubjectsOffcanvasAccordion() {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { accordionTarget: $this.element.dataset["accordionTarget"] }
if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id
} else {
params.is_root = true
}
if ($(opts.accordionTarget).find(".accordion-flush").length === 0) {
$.get("/api/subjects.json", params, function (search_results, status) {
if (status === "success") {
$this.stimulate("SubjectsReflex#render_subjects_offcanvas_accordion", search_results, opts)
}
})
}
}
loadDoctrinesOffcanvasAccordion() {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { accordionTarget: $this.element.dataset["accordionTarget"] }
if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id
} else {
params.is_root = true
}
if ($(opts.accordionTarget).find(".accordion-flush").length === 0) {
$.get("/api/subjects.json", params, function (search_results, status) {
if (status === "success") {
$this.stimulate("SubjectsReflex#render_doctrines_offcanvas_accordion", search_results, opts)
}
})
}
}
}

0
test/controllers/.keep → app/javascript/images/.keep

BIN
app/javascript/images/application/bg2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 508 KiB

BIN
app/javascript/images/application/cdao-bg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 KiB

BIN
app/javascript/images/application/cdasiaonline_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
app/javascript/images/application/search-icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

40
app/javascript/packs/application.js

@ -19,6 +19,7 @@ import "chosen-js";
import 'trix/dist/trix.css';
import 'trix/dist/trix.js';
import "cable_ready";
import "flatpickr/dist/flatpickr";
window.jQuery = $;
window.$ = $;
@ -27,27 +28,44 @@ Rails.start()
Turbolinks.start()
ActiveStorage.start()
const images = require.context('../images', true)
const imagePath = (name) => images(name, true)
$(document).on("ready turbolinks:load", function () {
$('#toggleSideNav').on('click', function () {
$('#sidenav').toggleClass('active');
});
$(".clickable-link").on("click", function (e) {
e.preventDefault();
let $href = $(this).attr("href");
if ($href !== undefined) {
window.location.href = $href;
}
$("#toast-close").click(function(){
$('.toast').hide();
});
$(".clickable-tr").on("click", function () {
let $href = $(this).attr("href");
if ($href !== undefined) {
window.open($href);
$(".spinner-border").hide();
var default_config = { altFormat: "m/d/Y", altInput: true, enableTime: false, dateFormat: "Y-m-d", isMobile: true };
$('.default-flatpickr').flatpickr(default_config);
if ($.fn.footnotes) {
$('#documentTabContent').footnotes()
}
$(document).on('click', 'a[href="#footnotes"]', function(event){
$(this).each(function(){
var a, b, c, d;
a = $(this), b = a.attr('href'), c = a.text(), d = '#footnote' + c
a.attr('href', d), a.attr('id', 'fn' + c)
a.trigger('click')
})
event.preventDefault();
}).on('click', 'a[href^="#footnote"], a[href^="#fn"]', function(event){
var a, b;
a = $(this), b = $(a.attr('href'))
if(b.length<=0)return
event.preventDefault()
document.getElementById(b[0].id).scrollIntoView( {behavior: "smooth", duration: 700 })
})
});
import "channels"
import "controllers"
import "./application/footnotes"

144
app/javascript/packs/application/footnotes.js

@ -0,0 +1,144 @@
(function ($) {
'use strict';
$.fn.footnotes = function () {
var a, b, c;
a = $(this), b = a.find('a[href^="#footnote"]')
c = a.find('p>span, p>a[href^="#fn"]>span').filter(function() {
return ($(this).css('color') == 'rgb(255, 0, 0)')
})
b.each(function(){
var $this = $(this);
if($this.anchor_check()){
if(!$this.parent('span.footnote-x').length){
// Wrap the anchor with 'footnote-x'
$this.wrap('<span class="footnote-x"></span>')
}
}
})
// Append index to every anchor
b = a.find('span.footnote-x a[href^="#footnote"]')
b.each(function(){
var $this = $(this);
var $matches = $($this.prop("tagName") + '#' + $this.attr("id") + ':not([data-index])')
var index = 0;
$matches.each(function(){
$(this).attr('id', $(this).attr('id') + '_' + index)
$(this).attr('name', $(this).attr('name') + '_' + index)
$(this).attr('href', $(this).attr('href') + '_' + index)
$(this).attr('data-index', index)
index = index + 1;
})
})
c.each(function(){
var $this = $(this)
$this.footnote_check()
})
c = a.find('a[href^="#fn"]')
c.each(function(){
var $this = $(this);
var $matches = $($this.prop("tagName") + '#' + $this.attr("id") + ':not([data-index])')
var index = 0;
$matches.each(function(){
var self, parent
self = $(this), parent = self.parent()
self.closest('p').find('#cdasiatab').detach()
self.attr('id', self.attr('id') + '_' + index)
self.attr('name', self.attr('name') + '_' + index)
self.attr('href', self.attr('href') + '_' + index)
self.attr('data-index', index)
parent.is('a') ? parent.replaceWith(self) : parent.closest('a').replaceWith(parent) // Remove parent its parent 'a' tag
index = index + 1;
})
})
}
$.fn.anchor_check = function () {
var a, b, c, d;
a = $(this), b = a.attr('href'), c = $.trim(a.text())
if(!$.isNumeric($.trim(c)) && c != '*' && c != 'n'){return false}
if($.trim(b) && a.is('[href^="#footnote"]')){
// Check whether href, name and text is valid
var a_href_id = a.attr('href').substring(9) // Get only the value after '#footnote'
var a_name_id = a.attr('name') ? a.attr('name').substring(2) : a_href_id // Get only the value after 'fn' if name attr is present if not return a_href_id
var a_id = a.attr('id') ? a.attr('id').substring(2) : ''
if(a_href_id != a_name_id || a_href_id != c || a_id != c || a_name_id != c){
a.attr('href', '#footnote' + c), a.attr('id', 'fn' + c), a.attr('name', 'fn' + c)
}
}else{
// If anchor to footnote is invalid by href=#footnote*** or no href
// the text inside the 'a' tag will use as a reference
a.attr('href', '#footnote' + c), a.attr('id', 'fn' + c), a.attr('name', 'fn' + c)
}
return true;
}
$.fn.footnote_check = function () {
var a, b, c, d;
a = $(this), d = null
if(a.find('a:not([href^="#footnote"])').length){
a.find('a').each(function(){
b = $.trim($(this).text()), c = b.match(/([\*]{1,3}|[\d]{1,3})/)
if(c!= null){
c = c[0]
d = $(document.createElement('a'))
d.text(b), d.attr('href', '#fn' + c), d.attr('id', 'footnote' + c), d.attr('name', 'footnote' + c), d.addClass('m-r-lg'), d.css('color', 'red')
a.html(''), a.append(d)
return true;
}
})
if(d=null){
return false
}
}else if(!a.find('a').length){
b = $.trim(a.text()), c = b.match(/([\*]{1,3}|[\d]{1,3})/)
if(c!= null){
c = c[0]
d = $(document.createElement('a'))
d.text(b), d.attr('href', '#fn' + c), d.attr('id', 'footnote' + c), d.attr('name', 'footnote' + c), d.addClass('m-r-lg'), d.css('color', 'red')
a.html(''), a.append(d)
}else{
return false
}
}
return true
}
$.fn.footnote = function () {
var a = $(this)
// Validation of footnote
var b, c, d;
b = $(a.attr('href'))
if(b.length<=0 && a.data('index')>0){
var a_id = a.attr('id').substring(0, a.attr('id').indexOf('_'))
var a_like = $('a[href^="#footnote"][id^="' + a_id + '"]')
var a_found = false;
a_like.each(function(){
if(!a_found){b = $($(this).attr('href'))}
a_found = b.length>0
})
}
if(b.length>0){
c = b.closest('p')
d = c.footnote_text(b.parent('span') || b), d = d.substring(0,499) + (d.length > 500 ? '...' : '')
a.attr('data-original-title', d), a.attr('data-toggle', 'tooltip')
a.tooltip({title: d}), a.tooltip('show')
}else{
// typeof a._errorReport === "function" && a._errorReport({
// type: 'footnote',
// details: 'Footnote not found @ ' + a.attr('href')
// })
}
return a
}
$.fn.footnote_text = function (except) {
var a = '';
$(this).children().not(except).each(function(){
// Check first if the current select element not equal to except
var self = $(this)
a += self.text()
})
return a;
}
$(document).on('mouseover mouseenter focus', 'a[href^="#footnote"]', function(event){
event.preventDefault()
$(this).footnote()
})
}(jQuery))

52
app/javascript/src/application.scss

@ -1,8 +1,14 @@
@import "~bootstrap/scss/bootstrap";
@import '~flatpickr/dist/flatpickr.min';
@import '~flatpickr/dist/themes/airbnb';
@import "./application/sidenav";
@import "./application/sessions";
@import "./application/pagination";
@import "./application/table";
@import "./application/nav-bar";
@import "./application/document-search";
@import "./application/offcanvas";
@import "./application/subject-accordion";
.tableFixHead {
overflow: auto;
@ -20,7 +26,7 @@
left: 0;
}
.clickable-link, .clickable-tr, .accordion-button {
.clickable-link, .clickable-tr, .accordion-button, .page-item, .page-link {
cursor: pointer;
}
@ -43,7 +49,7 @@
// Modal Form custom styling //
.modal-doctrine-body .selectize-control {
.selectize-control {
border: none !important;
}
@ -103,3 +109,45 @@
padding-left: 5px;
background: #efefef;
}
.sessions-body-bg {
background-image: url('../../javascript/images/application/bg2.png');
background-repeat: no-repeat;
background-size: cover;
overflow-x: hidden;
// box-shadow: inset 0 0 0 2000px rgba(251, 251, 251, 0.3);
}
.subject-ids-selectize {
width: auto !important;
}
.not-full input {
width: auto !important;
}
// Footnotes
.footnote-x a {
font-size:12px; vertical-align: 20%;
color: red;
font-weight: bold;
text-decoration: none;
}
.footnote-x a.tip span{
display: none
}
.footnote-x a.tip:hover span{
border: #c0c0c0 1px dotted;
padding: 5px 20px 5px 5px;
display: block;
z-index: 100;
background-color: #87cefa;
left: 0px;
margin: 10px;
width: 250px;
position: absolute;
top: 10px;
text-decoration: none
}

31
app/javascript/src/application/document-search.scss

@ -0,0 +1,31 @@
.advanced-search-box {
padding: 20px;
background: #525962;
input {
margin-bottom: 20px;
}
}
.no-search-body {
padding-top: 70px;
.label-no-search {
font-size: 30px;
font-weight: 700;
}
.search-doc-icon {
width: 157px;
}
}
hr.simple {
border: 1px dotted #000;
border-style: none none dotted;
color: #fff;
background-color: #fff;
}
.doctrine-index-body {
width: 98% !important;
}

16
app/javascript/src/application/nav-bar.scss

@ -0,0 +1,16 @@
img.nav-bar-app-logo {
width: 220px;
}
.active-red {
background: #f75353;
}
.active-red a:hover {
background: transparent;
}
.nav-body {
box-shadow: 0 2px 2px rgb(0 0 0 / 5%), 0 1px 0 rgb(0 0 0 / 5%);
background: #fff;
}

125
app/javascript/src/application/offcanvas.scss

@ -0,0 +1,125 @@
.offcanvas-contents {
width: auto !important;
min-width: 400px !important;
box-shadow: 0 0 15px -5px #000 !important;
}
.offcanvas-contents .offcanvas-item.accordion, .accordion-item {
border: none !important;
}
.offcanvas-contents .offcanvas-item .accordion-button:not(.collapsed) {
background-color: #fff;
a {
color: darkred !important;
font-weight: 600;
}
}
.for-body-grid.sub-body1{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
// max-width: 500px;
padding-left: 10px !important;
}
.for-body-grid.sub-body2{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
max-width: 600px;
padding-left: 20px!important;
}
.for-body-grid.sub-body3{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
max-width: 700px;
padding-left: 30px!important;
}
.for-body-grid.sub-body4{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
max-width: 800px;
padding-left: 40px!important;
}
.for-body-grid.sub-body5{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
max-width: 900px;
padding-left: 50px!important;
}
.for-body-grid.sub-body6{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
max-width: 1000px;
padding-left: 60px!important;
}
.for-body-grid.sub-body7{
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 10px;
max-width: 1000px;
padding-left: 70px!important;
}
.sub-body1{
width: auto;
max-width: 1200px;
padding-left: 10px !important;
padding-right: 0 !important;
}
.sub-body2{
width: auto;
max-width: 1000px;
padding-left: 20px!important;
padding-right: 0 !important;
}
.sub-body3{
width: auto;
max-width: 1000px;
padding-left: 30px!important;
padding-right: 0 !important;
}
.sub-body4{
width: auto;
max-width: 1000px;
padding-left: 40px!important;
padding-right: 0 !important;
}
.sub-body5{
width: auto;
max-width: 1000px;
padding-left: 50px!important;
}
.sub-body6{
width: auto;
max-width: 1000px;
padding-left: 60px!important;
padding-right: 0 !important;
}
.sub-body7{
width: auto;
max-width: 1000px;
padding-left: 70px!important;
}
.offcanvas-header {
border-bottom: 1px solid #0000004d;
color: #00000099 !important;
}

28
app/javascript/src/application/pagination.scss

@ -3,7 +3,29 @@
}
.pagination-body .pagination span.page-item.page.current.page-link {
border: darkred;
background: darkred !important;
color: #fff !important;
border: darkred;
background: darkred !important;
color: #fff !important;
}
.label-breadcrumb a {
color: #1d1a1a;
font-size: 20px;
}
.label-breadcrumb a:hover {
color: darkred;
}
.breadcrumb-item.active h4 {
color: darkred !important;
}
.subject-index-body-show h4 a {
color: #1d1a1a !important;
font-size: 20px !important;
}
.subject-index-body-show h4 a:hover {
color: darkred !important;
}

17
app/javascript/src/application/sessions.scss

@ -1,6 +1,19 @@
.login-body-box .content-body {
padding: 26px;
background: #949494ba;
box-shadow: 10px 5px 5px #e8e8e8;
background: #9494946b;
box-shadow: 10px 5px 5px #7a6346;
border-radius: 4px;
width: 380px;
margin-left: 40px;
}
.login-logo {
height: 100%;
}
.login-logo {
.app-logo {
width: 330px;
margin-top: 15px;
}
}

69
app/javascript/src/application/sidenav.scss

@ -180,50 +180,18 @@
margin-left: -62px;
}
.accordion-body {
border: none !important;
padding: 0 !important;
}
.accordion-body .accordion-button {
border: none !important;
padding: 0 !important;
}
.accordion-button:focus {
outline: none !important;
box-shadow: none !important;
border-color: transparent !important;
}
.sub1 {
padding-left: 22px;
padding-top: 10px;
padding-bottom: 10px;
}
.sub2 {
padding-left: 40px;
padding-top: 10px;
padding-bottom: 10px;
}
.sub3 {
padding-left: 60px;
padding-top: 10px;
padding-bottom: 10px;
}
.sub4 {
padding-left: 80px;
padding-top: 10px;
padding-left: 10px;
font-weight: 500;
padding-right: 10px;
padding-bottom: 10px;
font-size: 1.1rem;
}
.sub5 {
padding-left: 100px;
padding-top: 10px;
.sub2, .sub3, .sub4, .sub5, .sub6, .sub7 {
padding-left: 10px;
padding-bottom: 10px;
padding-right: 10px;
}
.sidebar-body {
@ -235,3 +203,26 @@
color: #ffbca7 !important;
}
.navbar-body {
position: fixed !important;
z-index: 1000;
width: 100%;
}
.for-side-button {
background: darkred;
height: 180px;
padding-left: 0 !important;
position: absolute;
top: 36%;
width: 20px;
z-index: 1;
svg {
color: #fff !important;
font-size: 35px !important;
padding-left: 2px;
position: absolute !important;
top: 38% !important;
}
}

38
app/javascript/src/application/subject-accordion.scss

@ -0,0 +1,38 @@
.subject-body-index .accordion-item{
border-bottom: 1px solid #e5e5e5 !important;
}
.subject-body-index .accordion-button:not(.collapsed) {
background-color: #fff;
a {
color: darkred !important;
font-weight: 600;
}
}
.subject-body-index .sub-body1 {
max-width: 100% !important;
padding-bottom: 0 !important;
padding-left: 26px !important;
padding-right: 0 !important;
}
.subject-body-index .sub-body2, .sub-body3, .sub-body4, .sub-body5, .sub-body6, .sub-body7 {
max-width: 100% !important;
padding-bottom: 0 !important;
padding-right: 0 !important;
}
.non-toggle {
margin-right: 65px !important;
}
.sub-icon-add a {
font-size: large;
color: #4caf50;
}
.sub-icon-add a:hover {
color: darkred;
}

66
app/jobs/parse_linkable_content_job.rb

@ -0,0 +1,66 @@
class ParseLinkableContentJob < ActiveJob::Base
queue_as :default
def perform(annotation)
content = ""
document = annotation.document
citing_docs = annotation.documents
if annotation.content.present?
content = annotation.content.gsub("<div>", "").gsub("</div>", "")
contents = content.split(" citing ")
contents.each_with_index do |content, i|
linkable_content = nil
if i.eql?(0)
linkable_content = add_linkable_content(document.id, [content[i], clean_phil_rep(annotation)].reject(&:blank?).join(", "))
else
citing_docs.each do |citing_doc|
old_content = contents[i]
next if !old_content.include?(citing_doc.clean_reference_number)
linkable_content = add_linkable_content(citing_doc.id, old_content)
end
end
contents[i] = linkable_content
end
content = contents.join(" citing ")
else
contents = []
doc_title = document.short_title || document.title
doc_date_or_year = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year
doc_ref_num = document.clean_reference_number
contents << add_linkable_content(document.id, [doc_title, doc_ref_num, doc_date_or_year, clean_phil_rep(annotation)].reject(&:blank?).join(", "))
if citing_docs.present?
citing_docs.each do |citing_doc|
citing_doc_title = citing_doc.short_title || citing_doc.title
citing_doc_date_or_year = citing_doc.doc_date.present? ? citing_doc.doc_date.strftime("%B %d, %Y") : citing_doc.year
citing_doc_ref_num = citing_doc.clean_reference_number
citing_content = [citing_doc_title, citing_doc_date_or_year, citing_doc_ref_num].join(", ")
contents << ["citing", add_linkable_content(citing_doc, citing_content)].join(" ")
end
end
content = contents.join(", ")
end
annotation.update_column(:content, content) if content.present?
annotation.index!
end
private
def add_linkable_content(document_id, content)
document_route = Rails.application.routes.url_helpers.document_path(document_id)
"<a href='#{document_route}'> #{content} </a>"
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
end

17
app/models/annotation.rb

@ -11,6 +11,8 @@ class Annotation < ApplicationRecord
has_many :annotation_annomarks, dependent: :destroy
has_many :annomarks, through: :annotation_annomarks
validates :content, presence: true
def documents
annotation_documents.collect(&:document)
end
@ -33,6 +35,21 @@ class Annotation < ApplicationRecord
integer :document_id
integer :doctrine_id
integer :library_rank do
document.library.rank
end
integer :search_year do
document.year.present? && document.year > 0 ? document.year : (document.doc_date.try :year)
end
date :search_doc_date do
document.doc_date.presence || Date.new(year.presence || 0)
end
date :created_at
date :updated_at
text :phil_rep
string :phil_rep

2
app/models/cdao/citation_finder.rb

@ -4,7 +4,7 @@ class Cdao::CitationFinder < Cdao::Base
TYPES = %w[SCRA PhilRep].freeze
belongs_to :jurisprudence, class_name: "Cdao::Jurisprudence", optional: false
delegate :title, :content, :ponente, :syllabus, :reference_number, :docdate, to: :jurisprudence
delegate :title, :content, :ponente, :reference_number, :docdate, to: :jurisprudence
def display_name
@display_name || set_display_name

23
app/models/cdao/document.rb

@ -1,6 +1,8 @@
class Cdao::Document < Cdao::Base
self.table_name = "documents"
belongs_to :library, class_name: "Cdao::Library", optional: false
alias_attribute :docdate, :doc_date
alias_attribute :short_title, :title
@ -12,6 +14,15 @@ class Cdao::Document < Cdao::Base
(reference_number.presence || "").gsub(/<!--\d+-->/, "")
end
def doc_date_display
doc_date.present? ? doc_date.strftime("%B %d, %Y") : year
end
def display_text
title_display = short_title || title
[title_display, clean_reference_number, doc_date_display].join(", ")
end
def libraries
Cdao::DocumentLibrary.where(library_product_type: doc_type, library_product_id: doc_id).map(&:library)
end
@ -20,6 +31,13 @@ class Cdao::Document < Cdao::Base
libraries.all?(&:premium?)
end
def content
table_name = self.doc_type.tableize
sql = "select * from #{table_name} where id='#{self.doc_id}' LIMIT 1"
query = Cdao::Base.connection.execute(sql)
query.first.present? ? query.first["content"] : ""
end
def to_builder(ability = nil)
Jbuilder.new do |doc|
doc.(self, *%i[id title short_title])
@ -69,6 +87,11 @@ class Cdao::Document < Cdao::Base
integer :id
integer :year
integer :library_rank do
library.rank
end
integer :search_year do
year.present? && year > 0 ? year : (doc_date.try :year)
end

16
app/models/cdao/jurisprudence.rb

@ -1,9 +1,11 @@
class Cdao::Jurisprudence < Cdao::Base
self.table_name = "jurisprudences"
has_one :document, as: :doc, class_name: "Jurisprudence", dependent: :destroy
has_many :annotations, as: :document, dependent: :restrict_with_error
has_many :doctrines, as: :document, dependent: :restrict_with_error
has_many :doctrine_jurisprudences, dependent: :destroy
has_many :doctrines, through: :doctrine_jurisprudences
has_many :annotation_documents, as: :document, dependent: :restrict_with_error
has_many :annotations_as_cited, through: :annotation_documents, source: :annotation
@ -28,6 +30,10 @@ class Cdao::Jurisprudence < Cdao::Base
Cdao::Citation.where(cited_doc_id: self.id, cited_doc_type: self.class.name.gsub("Cdao::", ""))
end
def document
Cdao::Document.where(doc_id: self.id, doc_type: self.class.name.gsub("Cdao::", "")).first
end
def self.citing_docs_of(doc, where = {})
citing_docs = []
c_arel = Cdao::Citation.arel_table
@ -131,15 +137,19 @@ class Cdao::Jurisprudence < Cdao::Base
text :reference_number, stored: true
text :title, stored: true
text :short_title, stored: true
text :ponente, stored: true
string :reference_number
string :ponente
string :title do
(title.present? ? title.first(32760).strip : short_title || "").titleize
end
string :short_title do
(short_title.presence || title.first(32760).strip || "").titleize
end
string :citation_finders_names, multiple: true
string :citation_finders_names, multiple: true do
citation_finders_names
end
date :doc_date
date :search_doc_date do
@ -158,7 +168,5 @@ class Cdao::Jurisprudence < Cdao::Base
boolean :is_only_in_premium_libraries do
is_only_in_premium_libraries?
end
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :document_id, :to => :id })
end
end

39
app/models/cdao/subject.rb

@ -1,10 +1,14 @@
require "csv"
class Cdao::Subject < Cdao::Base
default_scope { joins(:library_subjects)
.where(cdao_library_subjects: { library_id: [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] }) }
has_paper_trail
has_ancestry
has_many :library_subjects, dependent: :restrict_with_error
has_many :library_subjects, dependent: :destroy
accepts_nested_attributes_for :library_subjects, allow_destroy: true
has_many :libraries, through: :library_subjects
@ -37,7 +41,7 @@ class Cdao::Subject < Cdao::Base
end
def lineage_name
path.map(&:name).join("; ")
path.map(&:name).join(" > ")
end
def name_with_product_names
@ -48,6 +52,37 @@ class Cdao::Subject < Cdao::Base
[name, "(#{product_names})"].join(" ")
end
def self.parse_csv_file(path)
::CSV.foreach(path).each_with_index do |data, index|
next if data[0].blank?
names = data[0].split("; ").map(&:strip)
root_name = names[0]
sub1_name = names[1]
sub2_name = names[2]
sub3_name = names[3]
sub4_name = names[4]
sub5_name = names[5]
sub6_name = names[6]
root = Cdao::Subject.find_or_create_by(name: root_name, ancestry: nil) if root_name.present?
root.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if root.persisted?
sub1 = root.children.find_or_create_by(name: sub1_name) if root.present? && sub1_name.present?
sub1.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub1.present? && sub1.persisted?
sub2 = sub1.children.find_or_create_by(name: sub2_name) if sub1.present? && sub2_name.present?
sub2.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub2.present? && sub2.persisted?
sub3 = sub2.children.find_or_create_by(name: sub3_name) if sub2.present? && sub3_name.present?
sub3.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub3.present? && sub3.persisted?
sub4 = sub3.children.find_or_create_by(name: sub4_name) if sub3.present? && sub4_name.present?
sub4.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub4.present? && sub4.persisted?
sub5 = sub4.children.find_or_create_by(name: sub5_name) if sub4.present? && sub5_name.present?
sub5.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub5.present? && sub5.persisted?
sub6 = sub5.children.find_or_create_by(name: sub6_name) if sub5.present? && sub6_name.present?
sub6.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub6.present? && sub6.persisted?
end
end
searchable do
integer :id
integer :parent_id

149
app/models/doctrine.rb

@ -1,5 +1,8 @@
require "csv"
class Doctrine < ApplicationRecord
belongs_to :document, polymorphic: true, optional: false
has_many :doctrine_jurisprudences, dependent: :destroy
has_many :jurisprudences, class_name: "Cdao::Jurisprudence", through: :doctrine_jurisprudences
has_many :doctrine_subjects, dependent: :destroy
has_many :subjects, through: :doctrine_subjects
@ -7,7 +10,6 @@ class Doctrine < ApplicationRecord
has_many :annotations, dependent: :destroy
validates :content, presence: true
validates :content_fingerprint, uniqueness: { scope: %i[document_id document_type] }
before_validation do
self.content_fingerprint = Digest::SHA256.hexdigest(content)
@ -17,6 +19,14 @@ class Doctrine < ApplicationRecord
DoctrineSubject.where(doctrine_id: self.id)
end
def jurisprudences
Cdao::Jurisprudence.where(id: doctrine_jurisprudences.map(&:jurisprudence_id)).order(year: :desc, docdate: :desc)
end
def jurisprudence
jurisprudences.first
end
def subjects
Cdao::Subject.where(id: doctrine_subjects.map(&:subject_id))
end
@ -47,11 +57,133 @@ class Doctrine < ApplicationRecord
Sanitize.clean(content).strip
end
def self.parse_csv_file(parent_id, path)
::CSV.foreach(path).each_with_index do |data, index|
row_no = index + 1
subject_name = data[0].strip
headnote = data[1].strip
content = data[2].strip
doc_url = data[6].strip
next if [headnote, content, doc_url].any?(&:blank?)
parent = Cdao::Subject.find(parent_id)
subject = parent.descendants.find_or_initialize_by(name: subject_name)
if subject.new_record?
subject.save
subject.library_ids = [27]
end
logger = Logger.new(Rails.root.join("log/import.doctrines.log"))
if subject.blank?
logger.info "[#{row_no}] - no subject found"
next
end
subject_id = subject.id
doc_id = doc_url.split("?").first.split("/").map(&:strip).last
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save
record.doctrine_subjects.find_or_create_by(subject_id: subject_id)
record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id)
else
logger.info "[#{row_no}] - failed to save #{record.errors.inspect}"
end
end
end
def self.parse_csv_file_new(parent_id, path)
::CSV.foreach(path).each_with_index do |data, index|
row_no = index + 1
subject_name = data[0].strip
headnote = ""
content = data[1].strip
doc_url = data[8].strip
# Annotations
annomark_name = (data[2] || "").strip
editor_note = (data[4] || "").strip
phil_rep = ""
doc_urls = (data[5] || "").strip.split("citing").map(&:strip)
if doc_urls.present?
anno_doc_url = doc_urls.first
citing_doc_url = doc_urls.count > 1 ? doc_urls.last : ""
end
next if [content, doc_url].any?(&:blank?)
parent = Cdao::Subject.find(parent_id)
subject = parent.descendants.find_or_initialize_by(name: subject_name)
if subject.new_record?
subject.save
subject.library_ids = [27]
end
logger = Logger.new(Rails.root.join("log/import.doctrines.log"))
if subject.blank?
logger.info "[#{row_no}] - no subject found"
next
end
subject_id = subject.id
doc_id = doc_url.split("?").first.split("/").map(&:strip).last
if anno_doc_url.present?
anno_doc_args = anno_doc_url.split("?").first.split("/").map(&:strip).last(2)
anno_doc_type = anno_doc_args.first.classify
anno_doc_id = anno_doc_args.last
annotation_document = Cdao::Document.find_by(doc_type: anno_doc_type, doc_id: anno_doc_id)
end
if citing_doc_url.present?
citing_doc_args = citing_doc_url.split("?").first.split("/").map(&:strip).last(2)
citing_doc_type = citing_doc_args.first.classify
citing_doc_id = citing_doc_args.last
citing_document = Cdao::Document.find_by(doc_type: citing_doc_type, doc_id: citing_doc_id)
end
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save
record.doctrine_subjects.find_or_create_by(subject_id: subject_id)
record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id)
# Annotations
phil_rep = ""
annomark = Annomark.find_by(name: annomark_name)
annotation = record.annotations.new
annotation.annomark_ids = [annomark.id] if annomark.present?
annotation.document = annotation_document
annotation.phil_rep = phil_rep || annotation_document.phil_rep
annotation.editor_notes = editor_note
if annotation.save
annotation.add_document(citing_document) if citing_document.present?
end
else
logger.info "[#{row_no}] - failed to save #{record.errors.inspect}"
end
end
end
searchable do
text :content
integer :id
integer :document_id
integer :jurisprudence_id do
jurisprudence.id
end
integer :subject_ids, multiple: true
@ -59,8 +191,17 @@ class Doctrine < ApplicationRecord
paper_trail.originator.to_i
end
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :annotation_doctrine_id, :to => :id })
integer :search_year do
jurisprudence.year.present? && jurisprudence.year > 0 ? jurisprudence.year : (jurisprudence.doc_date.try :year)
end
date :search_doc_date do
jurisprudence.doc_date.presence || Date.new(jurisprudence.year.presence || 0)
end
date :created_at
string :headnote
string :content
end
end

7
app/models/doctrine_jurisprudence.rb

@ -0,0 +1,7 @@
class DoctrineJurisprudence < ApplicationRecord
acts_as_list column: :rank, scope: %i[doctrine_id]
belongs_to :doctrine, optional: false
belongs_to :jurisprudence, class_name: "Cdao::Jurisprudence", optional: false
end

22
app/reflexes/annotation_reflex.rb

@ -1,8 +1,24 @@
# frozen_string_literal: true
class AnnotationReflex < ApplicationReflex
def render_document_search_results(results)
opts = { is_citing_document: true }
morph "tbody#documentSearchResultTable", render(partial: "document_search_results_table", locals: { search_results: results, opts: opts })
include DocumentSearch
include AnnotationSearch
def render_document_search_results(search_params)
search = document_search(search_params.merge(sort_by: %w[reference_number_texts title_texts short_title_texts]))
@documents = search.results
opts = { current_page: search_params[:page], q: search_params[:q] }
morph "#annotatedDocumentsSearchResults", render(partial: "/shared/annotated_documents_search_results", locals: { documents: @documents, opts: opts })
end
def render_annotations_views(search_params)
search = annotation_search(search_params)
@annotations = search.results
morph "#annotationsIndexView", render(partial: "/shared/annotations_index_view", locals: { annotations: @annotations,
opts: { doctrine_id: search_params[:doctrine_id], current_page: search_params[:page] } })
end
def render_default_case_lists_search(doctrine_id)
morph "#caseListsCollapse", render(partial: "/shared/case_lists_no_results", locals: { doctrine_id: doctrine_id })
end
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save