Skip to content
Snippets Groups Projects
Commit 75c3bab5 authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

add viewing report items copyable content

parent 93f0cf50
No related branches found
No related tags found
1 merge request!223Reports overhaul
......@@ -35,7 +35,8 @@ angular.module('reportApp')
link: function(scope){
scope.item = scope.reportItem;
scope.domId = `${scope.group.name}_${scope.id}`;
scope.showSerialized = { val: true };
scope.showSerialized = { val: false };
scope.serializeFuncObj = { val: () => 'UNDEFINED' };
},
template: `
<div class='row'>
......@@ -47,6 +48,7 @@ angular.module('reportApp')
group='group'
id='item.id'
show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
fields='item.content'
>
</div>
......@@ -57,6 +59,7 @@ angular.module('reportApp')
group='group'
id='item.id'
show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
content='item.content'
>
</div>
......@@ -66,6 +69,7 @@ angular.module('reportApp')
class='panel panel-default'
group='group'
show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
report-item='item'
>
</div>
......@@ -74,7 +78,8 @@ angular.module('reportApp')
group-view-serialized
ng-if='showSerialized.val'
class='col-md-6'
entity='fields'
entity='item'
serialize-func-obj='serializeFuncObj'
>
</div>
</div>
......
......@@ -32,7 +32,8 @@ angular.module('reportApp')
group: '=',
id: '=',
fields: '=',
showSerialized: '='
showSerialized: '=',
serializeFuncObj: '='
},
link: function(scope){
// add 'expName' to the beginning of the fields to show in the table
......@@ -115,6 +116,24 @@ angular.module('reportApp')
scope.domId = `${scope.group.name}_${scope.id}`;
scope.colSelectorId = `${scope.domId}_columnSelector`;
scope.serializeFuncObj.val = () => {
let fields = scope.fields;
let exps = scope.group.experiments
// clone arr
.map(e => `${e}`)
.sort((ea, eb) => (scope.sortField.isReversed ? -1 : 1) * (scope.sortFunc(ea) > scope.sortFunc(eb) ? -1 : 1))
;
let str = '';
let fieldsStr = fields.join(',');
let expsStrs = exps
.map(e => fields.map(f => `${scope.getFieldVal(e, f)}(${scope.getFieldType(f)})`).join(','))
.join('\n');
str = `${fieldsStr}\n${expsStrs}`;
return str;
};
},
template: `
<div id="{{domId}}-heading" class="panel-heading" role="tab">
......
......@@ -31,7 +31,8 @@ angular.module('reportApp')
scope: {
group: '=',
reportItem: '=',
showSerialized: '='
showSerialized: '=',
serializeFuncObj: '='
},
link: function(scope){
scope.item = scope.reportItem;
......@@ -49,17 +50,14 @@ angular.module('reportApp')
// the text editor
scope.editor;
scope.hasUnsavedContent = { val: false, change () { this.val = true; } };
scope.txt = { val: '' };
let setupEditor = (el) => {
scope.editor = new Quill(el, editorOptions);
if(typeof scope.item.content === 'object'){
scope.editor.setContents(scope.item.content);
scope.txt.val = scope.editor.getText();
}
scope.editor.on('text-change', (newDelta) => {
scope.hasUnsavedContent.change();
console.log(scope.hasUnsavedContent);
});
};
let editorId = `${scope.domId}-text-editor`;
......@@ -72,11 +70,12 @@ angular.module('reportApp')
);
scope.saveContent = () => {
console.log(scope.hasUnsavedContent);
let newContent = scope.editor.getContents();
scope.hasUnsavedContent.val = false;
scope.item.content = newContent;
scope.txt.val = scope.editor.getText();
};
scope.serializeFuncObj.val = () => scope.txt;
},
template: `
<div id="{{domId}}-heading" class="panel-heading" role="tab">
......@@ -103,9 +102,6 @@ angular.module('reportApp')
<button class='btn btn-danger' ng-click='group.removeReportItem(item.id)'>
Delete Text Block
</button
<div ng-if='hasUnsavedContent.val === true'>
<strong>Warning:</strong> Press the 'Save Content' button to save changes.
</div>
</h4>
</div>
<div id="collapse-{{domId}}"
......
......@@ -29,13 +29,16 @@ angular.module('reportApp')
.directive("groupViewSerialized", [function(){
return {
scope: {
entity: '='
entity: '=',
serializeFuncObj: '='
},
link: function(scope, el){
},
template: `
<div class='well'>
{{ entity }}
<pre>
{{ serializeFuncObj.val() }}
</pre>
</div>
`
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment