Skip to content

Commit

Permalink
bugfix (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoye authored Aug 15, 2019
1 parent 0838a7a commit 3a77194
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
21 changes: 18 additions & 3 deletions frontend/src/views/datamanager/DataList.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
<template>
<div>
<Row class="button-bar">
<Col span="24">
<Col span="23">
<b style="padding-left:5px">Mock Data Tree</b>
</Col>
<Col span="1">
<Dropdown v-show="false">
<a href="javascript:void(0)">
<Icon type="ios-more-outline" />
</a>
<DropdownMenu slot="list">
<DropdownItem>Import...</DropdownItem>
<DropdownItem>Export...</DropdownItem>
<DropdownItem>Reload</DropdownItem>
</DropdownMenu>
</Dropdown>
</Col>
</Row>
<DocumentTree :treeData="treeData" class="data-list"/>
<DocumentTree :treeData="treeData" class="data-list" />
</div>
</template>

Expand All @@ -16,7 +28,7 @@ export default {
DocumentTree
},
computed: {
treeData() {
treeData () {
return this.$store.state.dataManager.groupList
}
}
Expand Down Expand Up @@ -50,4 +62,7 @@ export default {
padding: 5px 0px 5px 10px;
cursor: pointer;
}
.button-bar-btn img {
width: 18px;
}
</style>
23 changes: 12 additions & 11 deletions lyrebird/mock/dm.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def add_data(self, parent_id, data):
else:
_data_name = data.get('name')
_data_rule = {'request.url': '(?=.*YOUR-REQUEST-PATH)(?=.*PARAMS)'}

if 'response' in data:
if 'data' in data['response']:
data['response']['data'] = self._flow_data_2_str(data['response']['data'])
Expand All @@ -223,12 +223,11 @@ def add_data(self, parent_id, data):
self.id_map[data_id] = data_node
self._save_prop()
return data_id

def _flow_data_2_str(self, data):
if isinstance(data, str):
return data
return json.dumps(data)

return json.dumps(data, ensure_ascii=False)

def add_group(self, parent_id, name):
if parent_id == None:
Expand Down Expand Up @@ -257,11 +256,6 @@ def add_group(self, parent_id, name):
return group_id

def delete(self, _id):
self._delete(_id)
# Save prop
self._save_prop()

def _delete(self, _id):
target_node = self.id_map.get(_id)
if not target_node:
raise IDNotFound(_id)
Expand All @@ -272,7 +266,14 @@ def _delete(self, _id):
parent['children'].remove(target_node)
else:
self.root['children'].remove(target_node)
# Delete children
self._delete(_id)
# Save prop
self._save_prop()

def _delete(self, _id):
target_node = self.id_map.get(_id)
if not target_node:
raise IDNotFound(_id)
if 'children' in target_node and len(target_node['children']) > 0:
for child in target_node['children']:
self._delete(child['id'])
Expand Down Expand Up @@ -351,7 +352,7 @@ def _save_prop(self):
# Save prop
prop_file = self.root_path / PROP_FILE_NAME
with codecs.open(prop_file, 'w') as f:
json.dump(self.root, f, ensure_ascii=False)
json.dump(self.root, f, ensure_ascii=False, indent=4)

"""
Conflict checker
Expand Down

0 comments on commit 3a77194

Please sign in to comment.