aleph_analytics 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@
3
3
 
4
4
  class QueryDetailsController {
5
5
  constructor(QueryHandler, QueryTab, TagResource, defaultDateFormat, DefaultAceConfigurator, OpenReplService,
6
- RoleModel) {
6
+ RoleModel, Query) {
7
7
  this._handler = QueryHandler;
8
8
  this._repl = OpenReplService;
9
9
  this._tags = TagResource;
@@ -11,6 +11,7 @@
11
11
  this._tabs = QueryTab;
12
12
  this.dateFormat = defaultDateFormat;
13
13
  this.aceLoaded = editor => new DefaultAceConfigurator(editor).readOnlyConfig();
14
+ this._Query = Query;
14
15
 
15
16
  RoleModel.initCollection();
16
17
  this._closeCommentDialog();
@@ -35,6 +36,15 @@
35
36
  this.resultRunner.run().then(this._tabs.navigateToTab.bind(this._tabs, 'results'));
36
37
  }
37
38
 
39
+ cloneQuery() {
40
+ let clone = this.query.clone();
41
+ clone._item.title = "Copy of " + clone._item.title;
42
+
43
+ clone.save()
44
+ .then(this._internalizeQueryItem.bind(this))
45
+ .then(this._handler.navigateToLatestVersion.bind(this._handler));
46
+ }
47
+
38
48
  deleteQuery() {
39
49
  this.query.destroy().then(this._handler.navigateToIndex.bind(this._handler));
40
50
  }
@@ -60,10 +70,16 @@
60
70
  this.form.$setPristine();
61
71
  return query;
62
72
  }
73
+
74
+ _internalizeQueryItem(queryItem) {
75
+ let query = new this._Query;
76
+ query.internalize(queryItem);
77
+ return query;
78
+ }
63
79
  }
64
80
 
65
81
  QueryDetailsController.$inject = ['QueryHandler', 'QueryTab', 'TagResource', 'defaultDateFormat',
66
- 'DefaultAceConfigurator', 'OpenReplService', 'RoleModel'];
82
+ 'DefaultAceConfigurator', 'OpenReplService', 'RoleModel', 'Query'];
67
83
 
68
84
  function queryDetailsComponent() {
69
85
  return {
@@ -37,6 +37,12 @@
37
37
  return this._resource.destroy({ id: this.item.id }).$promise.then(item => item);
38
38
  }
39
39
 
40
+ clone() {
41
+ let clone = angular.copy(this);
42
+ clone._item.id = undefined;
43
+ return clone;
44
+ }
45
+
40
46
  fetch(params) {
41
47
  return this._resource.show(params).$promise.then(i => {
42
48
  this.item = i;