Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ti 135 doc highlighting #25

Merged
merged 20 commits into from Apr 26, 2016
Expand Up @@ -33,8 +33,12 @@ <h5>categories:</h5>
</div>
</div>
<div class="detail vertical grid-content" ng-class="::{'small-8':vm.doc.lw_image, 'medium-10': vm.doc.lw_image, 'small-12':!vm.doc.lw_image}">
<!-- {{vm.doc}} -->
<!-- show head field linked with a url. -->
<h3 class="head-field" ng-if="::vm.doc.lw_url"><a ng-href="{{::vm.doc.lw_url}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">{{::vm.doc.lw_head}}</a></h3>
<h3 class="head-field" ng-if="::vm.doc.lw_url">
<a ng-href="{{::vm.doc.lw_url}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">{{::vm.doc.lw_head}}</a>

</h3>
<!-- show head field without a url. -->
<h3 class="head-field" ng-if="::(!vm.doc.lw_url)">{{::vm.doc.lw_head}}</h3>

Expand All @@ -43,8 +47,11 @@ <h4 class="subheader">{{::vm.doc.lw_subhead}}</h4>
{{::vm.doc.lw_description}}
</p>
<!-- Output of CONFIG BASED FIELD DISPLAY -->
<p ng-repeat = "(field, value) in vm.doc.fieldsToDisplay">
<span><strong>{{::field}}</strong>: {{::value}}</span>
<p ng-repeat="(field, value) in vm.doc.fieldsToDisplay">
<span><strong>{{::field}}: &nbsp; </strong></span>

<field value="::value" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="{{field}}"></field>

</p>
</div>
</article>
Expand Up @@ -6,16 +6,17 @@
<span class="doc-label">size:</span> <field value="::vm.doc.length_lFormatted"></field>
</div>
<div class="mimetype" ng-if="::vm.doc.mimeType_s">
<span class="doc-label">mimetype:</span> <field value="::vm.doc.mimeType_s" highlight="::vm.highlight" maxlength="200"
<span class="doc-label">mimetype:</span> <field value="::vm.doc.mimeType_s" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="mimeType_s"></field>
</div>
<div class="owner" ng-if="::vm.doc.owner_s">
<span class="doc-label">owner:</span> <field value="::vm.doc.owner_s" highlight="::vm.highlight" maxlength="200"
<span class="doc-label">owner:</span> <field value="::vm.doc.owner_s" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="owner_s"></field>
</div>
<div class="last-modified" ng-if="::vm.doc.lastModified_dt">
<span class="doc-label">last modified:</span> <field value="::vm.doc.lastModified_dtFormatted"></field> UTC
</div>

</div>
</div>
</article>
@@ -1,23 +1,24 @@
<div class="detail jira-issue vertical grid-content">

<h3 class="subheader">
<a ng-href="{{::vm.doc.id}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
<field value="::vm.doc.summary_s" highlight="::vm.highlight" maxlength="200" hkey="summary_s"></field>
<field value="::vm.doc.summary_s" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="summary_s"></field>
</a>
</h3>

<div class="large-8 xlarge-7 xx-large-6">
<p ng-if="::vm.doc.description_s">
<field value="::vm.doc.description_s" highlight="::vm.highlight" maxlength="200"
hkey="description_s"></field>
<p ng-if="::vm.doc.content_txt">
<field ng-if="::vm.doc.content_txt" value="vm.doc.content_txt" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="content_txt" ></field>
</p>

<div class="detail-row">
<div class="type" ng-if="::vm.doc.jira_content_type_s">
<field value="::vm.doc.jira_content_type_s" highlight="vm.highlight" maxlength="200"
<field value="::vm.doc.jira_content_type_s" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="jira_content_type_s"></field>
</div>
<div class="key" ng-if="::vm.doc.parent_s">
<a ng-href="{{::vm.doc.id}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
<field value="::vm.doc.key_s" highlight="::vm.highlight" maxlength="200" hkey="key_s"></field>
<field value="::vm.doc.key_s" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="key_s"></field>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using one time binding on some highlights and not others?

</a>
</div>
<div class="last-modified" ng-if="::vm.doc.lastModified_dt"><span class="doc-label">Last Modified:</span> <field value="::vm.doc.lastModified_dtFormatted"></field></div>
Expand Down
Expand Up @@ -32,11 +32,7 @@

function activate() {
vm.postSignal = SignalsService.postSignal;
vm.doc = processDocument(vm.doc);
}

function processDocument(doc) {
return doc;
}
}
})();
@@ -1,27 +1,32 @@
<div class="detail jira-issue vertical grid-content">
<h3 class="subheader">

<a ng-href="{{::vm.doc.id}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
<field value="::vm.doc.name_s" highlight="::vm.highlight" maxlength="200" hkey="name_s"></field>
<field value="::vm.doc.name_s" highlight="vm.highlight[doc.id]" maxlength="200" hkey="name_s"></field>
</a>
</h3>

<div class="large-8 xlarge-7 xx-large-6">
<p ng-if="::vm.doc.description_s">
<field value="::vm.doc.description_s" highlight="::vm.highlight" maxlength="200"
hkey="description_s"></field>
<p ng-if="::vm.doc.content_txt">
<field value="::vm.doc.content_txt" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="content_txt"></field>
</p>
<div class="detail-row">
<div class="type" ng-if="::vm.doc.jira_content_type_s">
<field value="::vm.doc.jira_content_type_s" highlight="vm.highlight" maxlength="200"
<field value="::vm.doc.jira_content_type_s" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="jira_content_type_s"></field>
</div>
<div class="key" ng-if="::vm.doc.parent_s">
<a ng-href="{{::vm.doc.id}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
<field value="::vm.doc.key_s" highlight="::vm.highlight" maxlength="200" hkey="key_s"></field>
<field value="::vm.doc.key_s" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="key_s"></field>
</a>
</div>
<div class="last-modified" ng-if="::vm.doc.lastModified_dt"><span class="doc-label">Last Modified:</span> <field value="::vm.doc.lastModified_dtFormatted"></field></div>
<div class="lead" ng-if="::vm.doc.lead_s"><span class="doc-label">Lead:</span> <field value="::vm.doc.lead_s" maxlength="200"></field></div>
<div class="last-modified" ng-if="::vm.doc.lastModified_dt">
<span class="doc-label">Last Modified:</span> <field value="::vm.doc.lastModified_dtFormatted"></field>
</div>
<div class="lead" ng-if="::vm.doc.lead_s">
<span class="doc-label">Lead:</span> <field value="::vm.doc.lead_s" maxlength="200"></field>
</div>
</div>
</div>
</div>
Expand Up @@ -2,16 +2,16 @@
<div class="detail vertical grid-content">
<div class="large-8 xlarge-7 xx-large-6">
<blockquote class="text">
<!-- <field value="::vm.doc.text" highlight="vm.highlight" maxlength="200" hkey="text"></field> -->
<p>{{::vm.doc.text | limitTo:200}}...</p>
<field value="::vm.doc.text_t" highlight="vm.highlight[doc.id]" maxlength="200" hkey="text_t"></field>
<!-- <p>{{::vm.doc.text | limitTo:200}}...</p> -->
</blockquote>
<div class="detail-row">
<div class="channel label secondary" ng-if="::vm.doc.channel_s">
<field value="::vm.doc.channel_s" highlight="::vm.highlight" maxlength="200"
<field value="::vm.doc.channel_s" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="channel_s"></field>
</div>
<div class="user" ng-if="::vm.doc.user_s">
@<field value="::vm.doc.user_s" highlight="::vm.highlight" maxlength="200" hkey="user_s"></field>
@<field value="::vm.doc.user_s" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="user_s"></field>
</div>
<div class="timestamp" ng-if="::vm.doc.timestamp_tdt">
<a ng-href="{{::vm.doc.id}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
Expand Down
Expand Up @@ -2,7 +2,7 @@
<div class="detail vertical grid-content">
<div class="twitter-tweet" data-lang="{{::vm.doc.userLang[0]}}">
<blockquote class="quote" lang="{{::vm.doc.userLang[0]}}" dir="ltr">
<field value="::vm.doc.tweet[0]" highlight="::vm.highlight" hkey="tweet"></field>
<field value="::vm.doc.tweet[0]" highlight="::vm.highlight[doc.id]" hkey="tweet[0]"></field>
</blockquote>
<div class="link">
<a class="author" ng-href="http://twitter.com/{{::vm.doc.userScreenName}}" ng-click="::vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">@<field value="vm.doc.userScreenName" highlight="::vm.highlight" maxlength="200" hkey="{{::userScreenName}}"></field></a>
Expand Down
21 changes: 15 additions & 6 deletions client/assets/components/document/document_web/document_web.html
Expand Up @@ -3,13 +3,13 @@
<!-- show head field linked with a title. -->
<h3 class="head-field" ng-if="::vm.doc.title">
<a ng-href="{{vm.doc.url[0]}}" ng-click="::vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
<field value="::vm.doc.title" highlight="::vm.highlight" maxlength="200" hkey="title"></field>
<field value="::vm.doc.title" highlight="vm.highlight[doc.id]" maxlength="200" hkey="title"></field>
</a>
</h3>
<!-- show head field without a title. -->
<h3 class="head-field" ng-if="::(!vm.doc.title && !!vm.doc.url)">
<a ng-href="{{::vm.doc.url[0]}}" ng-click="vm.postSignal(vm.doc.__signals_doc_id__)" rel="noopener" target="_blank">
<field value="::vm.doc.url" highlight="::vm.highlight" maxlength="200" hkey="url"></field>
<field value="::vm.doc.url" highlight="vm.highlight[vm.doc.id]" maxlength="200" hkey="url"></field>
</a>
</h3>
<h3 class="subheader" ng-if="::(!vm.doc.title && !vm.doc.url)">
Expand All @@ -19,12 +19,21 @@ <h3 class="subheader" ng-if="::(!vm.doc.title && !vm.doc.url)">
</h3>
<h4 class="subheader" ng-if="::vm.doc.keywords"><field value="::vm.doc.keywords" highlight="::vm.highlight" maxlength="200" hkey="keywords"></field></h4>


<p class="large-8 xlarge-7 xx-large-6">
<field ng-if="::vm.doc.description" value="::vm.doc.description" highlight="::vm.highlight" maxlength="200"
<field ng-if="::vm.doc.description" value="::vm.doc.description" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="description"></field>
<field ng-if="::(!vm.doc.description && vm.doc.og_description)" value="::vm.doc.og_description" highlight="::vm.highlight" maxlength="200"
<field ng-if="::(!vm.doc.description && vm.doc.og_description)" value="::vm.doc.og_description" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="description"></field>
<field ng-if="::vm.doc.content" value="::vm.doc.content" highlight="::vm.highlight" maxlength="200"
hkey="content"></field>
<field ng-if="::vm.doc.content_txt" value="::vm.doc.content_txt" highlight="::vm.highlight[doc.id]" maxlength="200"
hkey="content_txt"></field>



<field ng-if="vm.doc.body" value="vm.doc.body" highlight="::vm.highlight[doc.id]" maxlength="200" hkey="body"></field>

<!-- Other fields -->

</p>
</div>
</article>
Expand Up @@ -23,7 +23,7 @@

}

function Controller(SignalsService) {
function Controller(SignalsService, $log) {
'ngInject';
var vm = this;

Expand All @@ -32,6 +32,7 @@
/////////

function activate() {
$log.debug(vm.doc, vm.highlight);
vm.postSignal = SignalsService.postSignal;
}
}
Expand Down
3 changes: 3 additions & 0 deletions client/assets/components/documentList/_documentList.scss
@@ -0,0 +1,3 @@
#documentList{
em{ background-color:$highlight-color;}
}
3 changes: 3 additions & 0 deletions client/assets/components/documentList/documentList.html
Expand Up @@ -6,7 +6,10 @@
<document-slack ng-switch-when="lucid.slack/slack" doc="vm.decorateDocument(doc)" bind="doc" highlight="vm.highlighting"></document-slack>
<document-twitter ng-switch-when="lucid.twitter.search/twitter_search" bind="doc" doc="vm.decorateDocument(doc)" highlight="vm.highlighting"></document-twitter>
<document-twitter ng-switch-when="lucid.twitter.stream/twitter_stream" bind="doc" doc="vm.decorateDocument(doc)" highlight="vm.highlighting"></document-twitter>

<document-web ng-switch-when="lucid.anda/web" doc="vm.decorateDocument(doc)" bind="doc" highlight="vm.highlighting"></document-web>


<document-default ng-switch-default doc="vm.decorateDocument(doc)" bind="doc" highlight="vm.highlighting"></document-default>

</div>
Expand Down
13 changes: 8 additions & 5 deletions client/assets/components/documentList/documentList.js
Expand Up @@ -22,7 +22,7 @@
}


function Controller($sce, $anchorScroll, Orwell, SignalsService) {
function Controller($sce, $anchorScroll, Orwell, SignalsService, $log) {
'ngInject';
var vm = this;
vm.docs = [];
Expand All @@ -36,7 +36,6 @@

function activate() {
var resultsObservable = Orwell.getObservable('queryResults');

resultsObservable.addObserver(function (data) {
vm.docs = parseDocuments(data);
vm.highlighting = parseHighlighting(data);
Expand Down Expand Up @@ -78,6 +77,7 @@
if (data.hasOwnProperty('response')) {
docs = data.response.docs;
}
$log.debug(docs);
return docs;
}

Expand All @@ -87,22 +87,25 @@
* @return {object} The highlighting results.
*/
function parseHighlighting(data) {
var highlighting = {};
if (data.hasOwnProperty('highlighting')){
_.each(data.highlighting, function(value, key){
var vals = {};
if (value) {
_.each(Object.keys(value), function (key) {
$log.debug('highlight', value);
var val = value[key];
_.each(val, function(high){
vals[key] = $sce.trustAsHtml(high);
});
});
highlighting[key] = vals;
vm.highlighting[key] = vals;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using vm.highlighting here as opposed to a non attached variable? we are already going to assign the value in the activate function. I think this will have a slight performance cost which will grow with a large number of highlights.

Won't this trigger a watch event for each iteration of the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is worth fixing at the current moment.

}
});
}
return highlighting;
else{
vm.highlighting = {};
}
return vm.highlighting;
}
}
})();
1 change: 1 addition & 0 deletions client/assets/js/services/QueryService.js
Expand Up @@ -31,6 +31,7 @@

queryObservable.addObserver(function (query) {
QueryDataService.getQueryResults(query);

});

return {
Expand Down
1 change: 1 addition & 0 deletions client/assets/scss/_settings.scss
Expand Up @@ -106,6 +106,7 @@ $secondary-color: #e6e6e6;
// $info-color: #A0D3E8;
$success-color: #53bf67;
$warning-color: #e23700;
$highlight-color: #dfdfdf;
// $dark-color: #232323;
// $gray: #dfdfdf;
// $gray-dark: darken($gray, 8);
Expand Down