#!/usr/bin/env python3 import json with open('/home/mdares/.node-red/flows.json', 'r') as f: flows = json.load(f) print("REWRITING STOP MODAL TO MATCH SCRAP MODAL PATTERN") print("="*60) for node in flows: if node.get('id') == '1821c4842945ecd8': template = node.get('format', '') # STEP 1: Initialize stopPrompt in message handler (like scrapPrompt) init_pos = template.find("if (!scope.scrapPrompt)") if init_pos > 0: # Add stopPrompt initialization right after scrapPrompt scrap_init_end = template.find("};", init_pos) + 2 stop_init = ''' if (!scope.stopPrompt) { scope.stopPrompt = { show: false, selectedCategory: null, selectedReason: null, notes: '' }; }''' template = template[:scrap_init_end] + stop_init + template[scrap_init_end:] print("✅ Added stopPrompt initialization") # STEP 2: Replace stop modal HTML to use ng-show (like scrap) # Find current stop modal stop_modal_start = template.find('') if stop_modal_start > 0: # Find end of modal stop_modal_end = template.find('\n', stop_modal_start + 100) # Keep going until we find the actual end count = 0 pos = stop_modal_start while count < 3: # Modal has 3 nested divs pos = template.find('', pos + 1) count += 1 stop_modal_end = pos + 6 # Replace entire modal with ng-show version new_stop_modal = '''
Why are you stopping production?