Chaudhry Waleed commited on
Commit
80b74c1
·
1 Parent(s): bbaee6f

Deploy RICS v2 (senior baseline, CPU Spaces Dockerfile)

Browse files
Files changed (1) hide show
  1. frontend/index.html +30 -11
frontend/index.html CHANGED
@@ -2641,11 +2641,28 @@ function _sectionTitle(code) {
2641
  return (sec && sec.title) || code;
2642
  }
2643
 
2644
- /** green | yellow | white — no-info, unknown, and not-yet-graded all show white. */
 
 
 
 
 
 
 
2645
  function _chipState(code) {
2646
  const entry = _gradeEntry(code);
2647
- if (!entry) return { grade: 'white', stale: false };
2648
- const stale = entry.hash !== _noteHash(_topicChipNotes(code));
 
 
 
 
 
 
 
 
 
 
2649
  let grade = entry.grade;
2650
  if (grade === 'red' || grade === 'unknown' || grade === 'neutral') grade = 'white';
2651
  grade = ['green', 'yellow', 'white'].includes(grade) ? grade : 'white';
@@ -2659,7 +2676,7 @@ function _needsGrading(code) {
2659
  return _chipState(code).stale;
2660
  }
2661
 
2662
- /** Manual "Check note quality" — only chips the surveyor edited since last grade. */
2663
  function _editedSinceGrading(code) {
2664
  return _chipState(code).stale;
2665
  }
@@ -2675,7 +2692,7 @@ function updateTopicCoverageFoot() {
2675
  sections.forEach(sec => {
2676
  const st = _chipState(sec.code);
2677
  tally[st.grade] = (tally[st.grade] || 0) + 1;
2678
- if (st.stale) stale += 1;
2679
  });
2680
 
2681
  const parts = [`${tally.green} sufficient`, `${tally.yellow} limited`, `${tally.white} none`];
@@ -2764,12 +2781,14 @@ function updateTopicChip(code) {
2764
  if ((state.structureMode || 'rics') !== 'content') return;
2765
  const chip = Array.from(document.querySelectorAll('.topic-chip'))
2766
  .find(c => c.dataset.code === code);
2767
- if (!chip) return;
2768
- const st = _chipState(code);
2769
- ['green', 'yellow', 'white', 'red'].forEach(g => {
2770
- chip.classList.toggle(`is-${g}`, g === st.grade);
2771
- });
2772
- chip.classList.toggle('is-stale', st.stale);
 
 
2773
  updateTopicCoverageFoot();
2774
  syncNoteQualityButton();
2775
  }
 
2641
  return (sec && sec.title) || code;
2642
  }
2643
 
2644
+ /** green | yellow | white — no-info / unknown / not-yet-graded show white. */
2645
+ function _chipHasRealNotes(code) {
2646
+ const notes = String(_liveNotesForReviewChip(code) || _topicChipNotes(code) || '')
2647
+ .replace(/\r\n/g, '\n')
2648
+ .trim();
2649
+ return !!(notes && notes !== EMPTY_SUBSECTION);
2650
+ }
2651
+
2652
  function _chipState(code) {
2653
  const entry = _gradeEntry(code);
2654
+ const hasNotes = _chipHasRealNotes(code);
2655
+ if (!entry) {
2656
+ // Never graded: white. If the surveyor typed notes into a blank chip, mark
2657
+ // stale so Check note quality enables (previously only already-mapped chips
2658
+ // could go stale).
2659
+ return { grade: 'white', stale: hasNotes };
2660
+ }
2661
+ let stale = entry.hash !== _noteHash(_topicChipNotes(code));
2662
+ // Graded as empty/no-info, then manually filled — treat as edited.
2663
+ if (hasNotes && (entry.method === 'empty' || entry.hash === _noteHash(''))) {
2664
+ stale = true;
2665
+ }
2666
  let grade = entry.grade;
2667
  if (grade === 'red' || grade === 'unknown' || grade === 'neutral') grade = 'white';
2668
  grade = ['green', 'yellow', 'white'].includes(grade) ? grade : 'white';
 
2676
  return _chipState(code).stale;
2677
  }
2678
 
2679
+ /** Manual "Check note quality" — chips edited or newly filled since last grade. */
2680
  function _editedSinceGrading(code) {
2681
  return _chipState(code).stale;
2682
  }
 
2692
  sections.forEach(sec => {
2693
  const st = _chipState(sec.code);
2694
  tally[st.grade] = (tally[st.grade] || 0) + 1;
2695
+ if (_editedSinceGrading(sec.code)) stale += 1;
2696
  });
2697
 
2698
  const parts = [`${tally.green} sufficient`, `${tally.yellow} limited`, `${tally.white} none`];
 
2781
  if ((state.structureMode || 'rics') !== 'content') return;
2782
  const chip = Array.from(document.querySelectorAll('.topic-chip'))
2783
  .find(c => c.dataset.code === code);
2784
+ if (chip) {
2785
+ const st = _chipState(code);
2786
+ ['green', 'yellow', 'white', 'red'].forEach(g => {
2787
+ chip.classList.toggle(`is-${g}`, g === st.grade);
2788
+ });
2789
+ chip.classList.toggle('is-stale', st.stale);
2790
+ }
2791
+ // Always refresh the button — even when the RICS id has no matching chip node.
2792
  updateTopicCoverageFoot();
2793
  syncNoteQualityButton();
2794
  }