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') ...@@ -35,7 +35,8 @@ angular.module('reportApp')
link: function(scope){ link: function(scope){
scope.item = scope.reportItem; scope.item = scope.reportItem;
scope.domId = `${scope.group.name}_${scope.id}`; scope.domId = `${scope.group.name}_${scope.id}`;
scope.showSerialized = { val: true }; scope.showSerialized = { val: false };
scope.serializeFuncObj = { val: () => 'UNDEFINED' };
}, },
template: ` template: `
<div class='row'> <div class='row'>
...@@ -47,6 +48,7 @@ angular.module('reportApp') ...@@ -47,6 +48,7 @@ angular.module('reportApp')
group='group' group='group'
id='item.id' id='item.id'
show-serialized='showSerialized' show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
fields='item.content' fields='item.content'
> >
</div> </div>
...@@ -57,6 +59,7 @@ angular.module('reportApp') ...@@ -57,6 +59,7 @@ angular.module('reportApp')
group='group' group='group'
id='item.id' id='item.id'
show-serialized='showSerialized' show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
content='item.content' content='item.content'
> >
</div> </div>
...@@ -66,6 +69,7 @@ angular.module('reportApp') ...@@ -66,6 +69,7 @@ angular.module('reportApp')
class='panel panel-default' class='panel panel-default'
group='group' group='group'
show-serialized='showSerialized' show-serialized='showSerialized'
serialize-func-obj='serializeFuncObj'
report-item='item' report-item='item'
> >
</div> </div>
...@@ -74,7 +78,8 @@ angular.module('reportApp') ...@@ -74,7 +78,8 @@ angular.module('reportApp')
group-view-serialized group-view-serialized
ng-if='showSerialized.val' ng-if='showSerialized.val'
class='col-md-6' class='col-md-6'
entity='fields' entity='item'
serialize-func-obj='serializeFuncObj'
> >
</div> </div>
</div> </div>
......
...@@ -32,7 +32,8 @@ angular.module('reportApp') ...@@ -32,7 +32,8 @@ angular.module('reportApp')
group: '=', group: '=',
id: '=', id: '=',
fields: '=', fields: '=',
showSerialized: '=' showSerialized: '=',
serializeFuncObj: '='
}, },
link: function(scope){ link: function(scope){
// add 'expName' to the beginning of the fields to show in the table // add 'expName' to the beginning of the fields to show in the table
...@@ -115,6 +116,24 @@ angular.module('reportApp') ...@@ -115,6 +116,24 @@ angular.module('reportApp')
scope.domId = `${scope.group.name}_${scope.id}`; scope.domId = `${scope.group.name}_${scope.id}`;
scope.colSelectorId = `${scope.domId}_columnSelector`; 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: ` template: `
<div id="{{domId}}-heading" class="panel-heading" role="tab"> <div id="{{domId}}-heading" class="panel-heading" role="tab">
......
...@@ -31,7 +31,8 @@ angular.module('reportApp') ...@@ -31,7 +31,8 @@ angular.module('reportApp')
scope: { scope: {
group: '=', group: '=',
reportItem: '=', reportItem: '=',
showSerialized: '=' showSerialized: '=',
serializeFuncObj: '='
}, },
link: function(scope){ link: function(scope){
scope.item = scope.reportItem; scope.item = scope.reportItem;
...@@ -49,17 +50,14 @@ angular.module('reportApp') ...@@ -49,17 +50,14 @@ angular.module('reportApp')
// the text editor // the text editor
scope.editor; scope.editor;
scope.hasUnsavedContent = { val: false, change () { this.val = true; } }; scope.txt = { val: '' };
let setupEditor = (el) => { let setupEditor = (el) => {
scope.editor = new Quill(el, editorOptions); scope.editor = new Quill(el, editorOptions);
if(typeof scope.item.content === 'object'){ if(typeof scope.item.content === 'object'){
scope.editor.setContents(scope.item.content); 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`; let editorId = `${scope.domId}-text-editor`;
...@@ -72,11 +70,12 @@ angular.module('reportApp') ...@@ -72,11 +70,12 @@ angular.module('reportApp')
); );
scope.saveContent = () => { scope.saveContent = () => {
console.log(scope.hasUnsavedContent);
let newContent = scope.editor.getContents(); let newContent = scope.editor.getContents();
scope.hasUnsavedContent.val = false;
scope.item.content = newContent; scope.item.content = newContent;
scope.txt.val = scope.editor.getText();
}; };
scope.serializeFuncObj.val = () => scope.txt;
}, },
template: ` template: `
<div id="{{domId}}-heading" class="panel-heading" role="tab"> <div id="{{domId}}-heading" class="panel-heading" role="tab">
...@@ -103,9 +102,6 @@ angular.module('reportApp') ...@@ -103,9 +102,6 @@ angular.module('reportApp')
<button class='btn btn-danger' ng-click='group.removeReportItem(item.id)'> <button class='btn btn-danger' ng-click='group.removeReportItem(item.id)'>
Delete Text Block Delete Text Block
</button </button
<div ng-if='hasUnsavedContent.val === true'>
<strong>Warning:</strong> Press the 'Save Content' button to save changes.
</div>
</h4> </h4>
</div> </div>
<div id="collapse-{{domId}}" <div id="collapse-{{domId}}"
......
...@@ -29,13 +29,16 @@ angular.module('reportApp') ...@@ -29,13 +29,16 @@ angular.module('reportApp')
.directive("groupViewSerialized", [function(){ .directive("groupViewSerialized", [function(){
return { return {
scope: { scope: {
entity: '=' entity: '=',
serializeFuncObj: '='
}, },
link: function(scope, el){ link: function(scope, el){
}, },
template: ` template: `
<div class='well'> <div class='well'>
{{ entity }} <pre>
{{ serializeFuncObj.val() }}
</pre>
</div> </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