Remove editor state tracking

Now that there is only one editor, and it doesn't get automatically
recycled as before, the state tracking is unnecessary.
This commit is contained in:
Oliver Hamlet
2016-03-05 16:23:38 +00:00
parent 880cbb3373
commit a3e022a0d7
5 changed files with 2 additions and 120 deletions
+2 -37
View File
@@ -12,28 +12,9 @@
<template>
<style>
/* Flip effect for user metadata / editor open icons. */
#flipper {
transform-style: preserve-3d;
transition: 0.6s;
overflow: visible;
}
#flipper.flipped {
transform: rotateY(180deg);
}
#hasUserEdits,
#editorIsOpen {
#hasUserEdits {
display: block;
margin-right: 0;
backface-visibility: hidden;
}
#hasUserEdits {
transform: translateZ(1px);
position: absolute;
top: 0;
left: 0;
}
#editorIsOpen {
transform: rotateY(180deg) translateZ(-1px);
}
/* paper-item (two-line) */
@@ -104,12 +85,8 @@
<span id="priority" hidden$="[[!priority]]">[[priority]]</span>
</div>
</paper-item-body>
<paper-tooltip for="editorIsOpen" position="left">Editor Is Open</paper-tooltip>
<iron-icon id="hasUserEdits" icon="account-circle" hidden$="[[!hasUserEdits]]"></iron-icon>
<paper-tooltip for="hasUserEdits" position="left">Has User Metadata</paper-tooltip>
<div id="flipper" class$="[[computeFlipperClass(isEditorOpen)]]">
<iron-icon id="editorIsOpen" icon="create"></iron-icon>
<iron-icon id="hasUserEdits" icon="account-circle" hidden$="[[!hasUserEdits]]"></iron-icon>
</div>
</paper-item>
</template>
<script>
@@ -127,11 +104,6 @@
value: false,
reflectToAttribute: true,
},
isEditorOpen: {
type: Boolean,
value: false,
reflectToAttribute: true,
},
hasUserEdits: {
type: Boolean,
value: false,
@@ -139,13 +111,6 @@
},
},
computeFlipperClass(isEditorOpen) {
if (isEditorOpen) {
return 'flipped';
}
return '';
},
getName() {
return this.textContent.trim();
},
-1
View File
@@ -167,7 +167,6 @@
data-index$="[[index]]"
priority="[[item.priority]]"
is-priority-global$="[[item.isPriorityGlobal]]"
is-editor-open$="[[item.isEditorOpen]]"
has-user-edits$="[[item.hasUserEdits]]">[[item.name]]</loot-plugin-item>
</template>
<!-- Generated <loot-plugin-item> elements go here. -->
-1
View File
@@ -84,7 +84,6 @@
pluginItem.querySelector('paper-tooltip[for=globalPriorityIcon]').textContent = l10n.translate('Global Priority');
pluginItem.querySelector('paper-tooltip[for=hasUserEdits]').textContent = l10n.translate('Has User Metadata');
pluginItem.querySelector('paper-tooltip[for=editorIsOpen]').textContent = l10n.translate('Editor Is Open');
}
function translateMessageDialogTemplate(l10n) {
-19
View File
@@ -186,7 +186,6 @@
/* UI state variables */
this.id = this.name.replace(/\s+/g, '');
this._isEditorOpen = false;
this.isConflictFilterChecked = false;
this._isSearchResult = false;
}
@@ -252,7 +251,6 @@
pluginId: this.id,
priority: this.priority,
isPriorityGlobal: this.isPriorityGlobal,
isEditorOpen: this.isEditorOpen,
hasUserEdits: this.hasUserEdits,
},
}));
@@ -391,18 +389,6 @@
}
}
get isEditorOpen() {
return this._isEditorOpen;
}
set isEditorOpen(isEditorOpen) {
if (this._isEditorOpen !== isEditorOpen) {
this._isEditorOpen = isEditorOpen;
this._dispatchItemContentChangeEvent();
}
}
get isSearchResult() {
return this._isSearchResult;
}
@@ -457,11 +443,6 @@
} else {
item.removeAttribute('is-priority-global');
}
if (evt.detail.isEditorOpen) {
item.setAttribute('is-editor-open', '');
} else {
item.removeAttribute('is-editor-open');
}
if (evt.detail.hasUserEdits) {
item.setAttribute('has-user-edits', '');
} else {
-62
View File
@@ -256,12 +256,6 @@ describe('Plugin', () => {
plugin.id.should.equal('testpluginname');
});
it('should set isEditorOpen to false', () => {
const plugin = new loot.Plugin({ name: 'test' });
plugin.isEditorOpen.should.be.false();
});
it('should set isConflictFilterChecked to false', () => {
const plugin = new loot.Plugin({ name: 'test' });
@@ -691,7 +685,6 @@ describe('Plugin', () => {
evt.detail.pluginId.should.equal(plugin.id);
evt.detail.priority.should.equal(plugin.priority);
evt.detail.isPriorityGlobal.should.equal(plugin.isPriorityGlobal);
evt.detail.isEditorOpen.should.equal(plugin.isEditorOpen);
evt.detail.hasUserEdits.should.equal(plugin.hasUserEdits);
done();
};
@@ -753,7 +746,6 @@ describe('Plugin', () => {
evt.detail.pluginId.should.equal(plugin.id);
evt.detail.priority.should.equal(plugin.priority);
evt.detail.isPriorityGlobal.should.equal(plugin.isPriorityGlobal);
evt.detail.isEditorOpen.should.equal(plugin.isEditorOpen);
evt.detail.hasUserEdits.should.equal(plugin.hasUserEdits);
done();
};
@@ -815,7 +807,6 @@ describe('Plugin', () => {
evt.detail.pluginId.should.equal(plugin.id);
evt.detail.priority.should.equal(plugin.priority);
evt.detail.isPriorityGlobal.should.equal(plugin.isPriorityGlobal);
evt.detail.isEditorOpen.should.equal(plugin.isEditorOpen);
evt.detail.hasUserEdits.should.equal(plugin.hasUserEdits);
done();
};
@@ -826,59 +817,6 @@ describe('Plugin', () => {
});
});
describe('#isEditorOpen', () => {
let handleEvent;
afterEach(() => {
document.removeEventListener('loot-plugin-item-content-change', handleEvent);
});
it('getting value should return false if it has not been set in the constructor', () => {
const plugin = new loot.Plugin({ name: 'test' });
plugin.isEditorOpen.should.be.false();
});
it('setting value should store set value', () => {
const plugin = new loot.Plugin({ name: 'test' });
plugin.isEditorOpen = true;
plugin.isEditorOpen.should.be.true();
});
it('setting value to the current value should not fire an event', (done) => {
const plugin = new loot.Plugin({ name: 'test' });
handleEvent = () => {
done(new Error('Should not have fired an event'));
};
document.addEventListener('loot-plugin-item-content-change', handleEvent);
plugin.isEditorOpen = plugin.isEditorOpen;
setTimeout(done, 100);
});
it('setting value not equal to the current value should fire an event', (done) => {
const plugin = new loot.Plugin({ name: 'test' });
handleEvent = (evt) => {
evt.detail.pluginId.should.equal(plugin.id);
evt.detail.priority.should.equal(plugin.priority);
evt.detail.isPriorityGlobal.should.equal(plugin.isPriorityGlobal);
evt.detail.isEditorOpen.should.equal(plugin.isEditorOpen);
evt.detail.hasUserEdits.should.equal(plugin.hasUserEdits);
done();
};
document.addEventListener('loot-plugin-item-content-change', handleEvent);
plugin.isEditorOpen = true;
});
});
describe('#isSearchResult', () => {
let handleEvent;