Skip to content

Commit

Permalink
Merge c234cc1 into 00d9f3c
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominionized committed Apr 18, 2017
2 parents 00d9f3c + c234cc1 commit 98a44e8
Show file tree
Hide file tree
Showing 39 changed files with 488 additions and 140 deletions.
10 changes: 6 additions & 4 deletions gulpTasks/templatesParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function parseDirectory(directory, conditions) {
path: path.dirname(path.relative(directory, template)),
content: content,
priority: condition != null ? condition.priority || 0 : -1,
layout: condition != null ? condition.layout : null
layout: condition != null ? condition.layout : null,
role: condition != null ? condition.role : null
};
buildRegisterTemplate(templateObj);
buildTemplateHtml(templateObj);
Expand All @@ -62,7 +63,8 @@ function buildRegisterTemplate(template) {
'condition': addToJsonIfNotNull(template, 'value'),
'layout': addToJsonIfNotNull(template, 'layout'),
'fieldsToMatch': addToJsonIfNotNull(template, 'fieldsToMatch'),
'mobile': addToJsonIfNotNull(template, 'mobile')
'mobile': addToJsonIfNotNull(template, 'mobile'),
'role': addToJsonIfNotNull(template, 'role')
}) + '),'
+
(!template.subtemplate).toString(),
Expand All @@ -74,9 +76,9 @@ function buildTemplateHtml(template) {
const cssClassName = 'result-template';
const type = template.type == 'HtmlTemplate' ? 'text/html' : 'text/underscore';
const layout = template.layout != null ? `data-layout="${template.layout}"` : '';
const role = template.role != null ? `data-role="${template.role}"`: '';
let fieldsCondition = '';
if (template.condition) {

if (template.condition.fieldsToMatch) {
template.condition.fieldsToMatch.forEach((fieldToMatch)=> {
fieldsCondition += `data-field-${fieldToMatch.field}`;
Expand All @@ -88,7 +90,7 @@ function buildTemplateHtml(template) {
});
}
}
template.html = `<script id="${template.name}" class="${cssClassName}" type="${type}" ${layout} ${fieldsCondition}>${template.content}</script>`
template.html = `<script id="${template.name}" class="${cssClassName}" type="${type}" ${layout} ${role} ${fieldsCondition}>${template.content}</script>`
}

function compileTemplates(directory, destination, fileName, conditions, done) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"devDependencies": {
"@salesforce-ux/design-system": "2.0.3",
"bluebird": "^3.4.7",
"@types/d3": "3.5.36",
"@types/d3-scale": "1.0.4",
"@types/fastclick": "^1.0.28",
Expand Down
2 changes: 1 addition & 1 deletion pages/All.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
<title>All Content</title>
Expand Down
2 changes: 1 addition & 1 deletion pages/Dropbox.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
2 changes: 1 addition & 1 deletion pages/Email.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
2 changes: 1 addition & 1 deletion pages/GoogleDrive.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
2 changes: 1 addition & 1 deletion pages/Jira.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
2 changes: 1 addition & 1 deletion pages/Lithium.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
2 changes: 1 addition & 1 deletion pages/Salesforce.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
2 changes: 1 addition & 1 deletion pages/SharePoint.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>

<head>
Expand Down
31 changes: 20 additions & 11 deletions sass/_Result.scss
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
}
}
// These divs are used for filling the space when the number of cards is not even
> div:empty {
&:empty {
width: 300px;
height: 0;
@include flex-grow(1);
Expand All @@ -205,16 +205,25 @@
}

.coveo-table-layout {
display: table;
border-collapse: collapse;
width: 100%;
margin-bottom: 20px;
> .CoveoResult {
display: table-row;
> * {
padding: .5em 0;
border-bottom: $default-border;
}
display: table-row;
td {
display: table-cell;
padding: 9px 15px;
white-space: nowrap;
border-bottom: $default-border;
overflow: hidden;
text-overflow: ellipsis;
}
th {
text-align: left;
font-size: 12px;
color: $color-greyish-teal-blue;
font-weight: bold;
border-bottom: $default-border;
padding: 7px 15px;
}
&:hover td {
background-color: $color-blueish-white-grey;
}
}

Expand Down
3 changes: 3 additions & 0 deletions sass/_ResultLayout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
.coveo-icon {
margin-right: 5px;
}
&.coveo-hidden {
display: none;
}
}
27 changes: 27 additions & 0 deletions sass/_ResultList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,43 @@
&.coveo-hidden {
display: none;
}

&[data-layout="table"] {
overflow-x: auto;
margin-bottom: 20px;
}
}

.coveo-card-layout-container {
@include display(flex);
@include flex-wrap(wrap);
margin-right: -20px;
@include mediaSelector(480) {
margin-right: 0;
}
}

.coveo-table-layout-container {
display: table;
white-space: nowrap;
table-layout: fixed;
border-collapse: collapse;
width: 100%;
}

.coveo-result-list-table-footer {
border-bottom: none;
}

@include mediaSelector(800) {
.CoveoResultList {
margin-left: 10px;
margin-right: 10px;
}
.coveo-table-layout-container {
table-layout: auto;
td {
max-width: 300px;
}
}
}
16 changes: 16 additions & 0 deletions sass/_Sort.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ $stop-float: new-breakpoint(max-width 480px 1);
position: relative;
top: 2px;
@extend .coveo-sprites-arrow-down;
&.coveo-hidden {
visibility: hidden;
}
}

&.coveo-ascending {
Expand All @@ -28,4 +31,17 @@ $stop-float: new-breakpoint(max-width 480px 1);
&.coveo-sort-hidden {
display: none;
}

&.coveo-table-header-sort {
text-transform: inherit;
padding-top: inherit;
padding-bottom: inherit;
display: table-cell;
}
}

.coveo-result-list-table-header .CoveoSort:not(.coveo-selected) {
.coveo-icon {
visibility: hidden;
}
}
2 changes: 0 additions & 2 deletions src/ui/ResponsiveComponents/ResponsiveComponentsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { $$, Dom } from '../../utils/Dom';
import { InitializationEvents } from '../../events/InitializationEvents';
import { Component } from '../Base/Component';
import { SearchInterface } from '../SearchInterface/SearchInterface';
import { ResponsiveComponentsUtils } from './ResponsiveComponentsUtils';
import { Utils } from '../../utils/Utils';
import { Facet } from '../Facet/Facet';
import { Tab } from '../Tab/Tab';
import { ResponsiveFacets } from './ResponsiveFacets';
import { QueryEvents } from '../../events/QueryEvents';
Expand Down
16 changes: 8 additions & 8 deletions src/ui/ResponsiveComponents/ResponsiveResultLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ export class ResponsiveResultLayout implements IResponsiveComponent {

public handleResizeEvent() {
if (this.needSmallMode()) {
this.enableAndDisableLayout(<ValidLayout[]>this.resultLayout.options.mobileLayouts);
this.enableAndDisableLayouts(<ValidLayout[]>this.resultLayout.options.mobileLayouts);
} else if (this.needMediumMode()) {
this.enableAndDisableLayout(<ValidLayout[]>this.resultLayout.options.tabletLayouts);
this.enableAndDisableLayouts(<ValidLayout[]>this.resultLayout.options.tabletLayouts);
} else {
this.enableAndDisableLayout(<ValidLayout[]>this.resultLayout.options.desktopLayouts);
this.enableAndDisableLayouts(<ValidLayout[]>this.resultLayout.options.desktopLayouts);
}
}

private enableAndDisableLayout(validLayouts: ValidLayout[]) {
let needToDisable = _.difference<any>(ResultLayout.validLayouts, validLayouts);
let needToEnable = _.intersection<any>(ResultLayout.validLayouts, validLayouts);
this.resultLayout.disableLayouts(needToDisable);
this.resultLayout.enableLayouts(needToEnable);
private enableAndDisableLayouts(validLayouts: ValidLayout[]) {
const layoutsToDisable = _.difference<any>(ResultLayout.validLayouts, validLayouts);
const layoutsToEnable = _.intersection<any>(ResultLayout.validLayouts, validLayouts);
this.resultLayout.disableLayouts(layoutsToDisable);
this.resultLayout.enableLayouts(layoutsToEnable);
}

private needSmallMode(): boolean {
Expand Down
15 changes: 6 additions & 9 deletions src/ui/ResultLayout/ResultLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export class ResultLayout extends Component {
Assert.check(this.isLayoutDisplayedByButton(layout), 'Layout not available or invalid');

if (layout !== this.currentLayout || this.getModelValue() === '') {

this.setModelValue(layout);
const lastResults = this.queryController.getLastResults();
this.setLayout(layout, lastResults);
Expand All @@ -164,13 +163,12 @@ export class ResultLayout extends Component {

public disableLayouts(layouts: ValidLayout[]) {
if (Utils.isNonEmptyArray(layouts)) {
_.each(layouts, (layout) => {
this.disableLayout(layout);
});
_.each(layouts, layout => this.disableLayout(layout));

let remainingValidLayouts = _.difference(_.keys(this.currentActiveLayouts), layouts);
if (remainingValidLayouts && remainingValidLayouts[0]) {
this.changeLayout(<ValidLayout>remainingValidLayouts[0]);
if (!_.isEmpty(remainingValidLayouts)) {
const newLayout = _.contains(remainingValidLayouts, this.currentLayout) ? this.currentLayout : remainingValidLayouts[0];
this.changeLayout(<ValidLayout>newLayout);
} else {
this.logger.error('Cannot disable the last valid layout ... Re-enabling the first one possible');
let firstPossibleValidLayout = <ValidLayout>_.keys(this.currentActiveLayouts)[0];
Expand Down Expand Up @@ -199,11 +197,10 @@ export class ResultLayout extends Component {
}
}


private hideButton(layout: ValidLayout) {
if (this.isLayoutDisplayedByButton(layout)) {
let btn = this.currentActiveLayouts[<string>layout].button;
$$(btn.el).hide();
$$(btn.el).addClass('coveo-hidden');
btn.visible = false;
this.updateSelectorAppearance();
}
Expand All @@ -212,7 +209,7 @@ export class ResultLayout extends Component {
private showButton(layout: ValidLayout) {
if (this.isLayoutDisplayedByButton(layout)) {
let btn = this.currentActiveLayouts[<string>layout].button;
$$(btn.el).show();
$$(btn.el).removeClass('coveo-hidden');
btn.visible = true;
}
}
Expand Down
Loading

0 comments on commit 98a44e8

Please sign in to comment.