Skip to content

Commit 2afbc47

Browse files
committed
fixed clearing for sections
1 parent 578048d commit 2afbc47

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

model/model.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,13 @@ def clear(self, list_name, indices=[], action='clear_all') -> None:
155155

156156
current_element = json_data['data'] if len(indices) == 0 else json_data['data'][indices[0]]
157157

158-
for i in indices[1:]:
159-
if isinstance(current_element[0], list):
160-
current_element = current_element[1]
161-
current_element = current_element[i]
158+
if len(indices) == 0:
159+
current_element = json_data['data']
160+
else:
161+
for i in indices:
162+
current_element = json_data['data'][i]
163+
if isinstance(current_element[0], list):
164+
current_element = current_element[1]
162165

163166
if action == 'clear_all':
164167
current_element.clear()
@@ -168,9 +171,9 @@ def clear(self, list_name, indices=[], action='clear_all') -> None:
168171
current_element.clear()
169172
current_element.extend(new_element)
170173
else:
171-
new_element = self.clear_checked(current_element[1], True if action == 'clear_all_checked' else False)
172-
current_element[1].clear()
173-
current_element[1].extend(new_element)
174+
new_element = self.clear_checked(current_element, True if action == 'clear_all_checked' else False)
175+
current_element.clear()
176+
current_element.extend(new_element)
174177

175178
json.dump(json_data, json_file, indent=4)
176179
json_file.truncate()

0 commit comments

Comments
 (0)