Skip to content

Build your personal knowledge base with Trilium Notes

added "type" to attribute dialog, name autocomplete servers according to the choice

azivner509093b75535
diff --git a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml
index 87b69781bd..2badc45a54 100644
--- a/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml
+++ b/.idea/dataSources/a2c75661-f9e2-478f-a69f-6a9409e69997.xml
@@ -12,732 +12,810 @@
<collation id="4" parent="1" name="NOCASE"/>
<collation id="5" parent="1" name="RTRIM"/>
<table id="6" parent="2" name="api_tokens"/>
- <table id="7" parent="2" name="branches"/>
- <table id="8" parent="2" name="event_log"/>
- <table id="9" parent="2" name="images"/>
- <table id="10" parent="2" name="labels"/>
- <table id="11" parent="2" name="note_images"/>
- <table id="12" parent="2" name="note_revisions"/>
- <table id="13" parent="2" name="notes"/>
- <table id="14" parent="2" name="options"/>
- <table id="15" parent="2" name="recent_notes"/>
- <table id="16" parent="2" name="relations"/>
- <table id="17" parent="2" name="source_ids"/>
- <table id="18" parent="2" name="sqlite_master">
+ <table id="7" parent="2" name="attributes"/>
+ <table id="8" parent="2" name="branches"/>
+ <table id="9" parent="2" name="event_log"/>
+ <table id="10" parent="2" name="images"/>
+ <table id="11" parent="2" name="labels"/>
+ <table id="12" parent="2" name="note_images"/>
+ <table id="13" parent="2" name="note_revisions"/>
+ <table id="14" parent="2" name="notes"/>
+ <table id="15" parent="2" name="options"/>
+ <table id="16" parent="2" name="recent_notes"/>
+ <table id="17" parent="2" name="relations"/>
+ <table id="18" parent="2" name="source_ids"/>
+ <table id="19" parent="2" name="sqlite_master">
<System>1</System>
</table>
- <table id="19" parent="2" name="sqlite_sequence">
+ <table id="20" parent="2" name="sqlite_sequence">
<System>1</System>
</table>
- <table id="20" parent="2" name="sync"/>
- <column id="21" parent="6" name="apiTokenId">
+ <table id="21" parent="2" name="sync"/>
+ <column id="22" parent="6" name="apiTokenId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="22" parent="6" name="token">
+ <column id="23" parent="6" name="token">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="23" parent="6" name="dateCreated">
+ <column id="24" parent="6" name="dateCreated">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="24" parent="6" name="isDeleted">
+ <column id="25" parent="6" name="isDeleted">
<Position>4</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="25" parent="6" name="hash">
+ <column id="26" parent="6" name="hash">
<Position>5</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <index id="26" parent="6" name="sqlite_autoindex_api_tokens_1">
+ <index id="27" parent="6" name="sqlite_autoindex_api_tokens_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>apiTokenId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <key id="27" parent="6">
+ <key id="28" parent="6">
<ColNames>apiTokenId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_api_tokens_1</UnderlyingIndexName>
</key>
- <column id="28" parent="7" name="branchId">
+ <column id="29" parent="7" name="attributeId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="29" parent="7" name="noteId">
+ <column id="30" parent="7" name="noteId">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="30" parent="7" name="parentNoteId">
+ <column id="31" parent="7" name="type">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="31" parent="7" name="notePosition">
+ <column id="32" parent="7" name="name">
+ <Position>4</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="33" parent="7" name="value">
+ <Position>5</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ <DefaultExpression>&apos;&apos;</DefaultExpression>
+ </column>
+ <column id="34" parent="7" name="position">
+ <Position>6</Position>
+ <DataType>INT|0s</DataType>
+ <NotNull>1</NotNull>
+ <DefaultExpression>0</DefaultExpression>
+ </column>
+ <column id="35" parent="7" name="dateCreated">
+ <Position>7</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="36" parent="7" name="dateModified">
+ <Position>8</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="37" parent="7" name="isDeleted">
+ <Position>9</Position>
+ <DataType>INT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="38" parent="7" name="hash">
+ <Position>10</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ <DefaultExpression>&quot;&quot;</DefaultExpression>
+ </column>
+ <index id="39" parent="7" name="sqlite_autoindex_attributes_1">
+ <NameSurrogate>1</NameSurrogate>
+ <ColNames>attributeId</ColNames>
+ <ColumnCollations></ColumnCollations>
+ <Unique>1</Unique>
+ </index>
+ <key id="40" parent="7">
+ <ColNames>attributeId</ColNames>
+ <Primary>1</Primary>
+ <UnderlyingIndexName>sqlite_autoindex_attributes_1</UnderlyingIndexName>
+ </key>
+ <column id="41" parent="8" name="branchId">
+ <Position>1</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="42" parent="8" name="noteId">
+ <Position>2</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="43" parent="8" name="parentNoteId">
+ <Position>3</Position>
+ <DataType>TEXT|0s</DataType>
+ <NotNull>1</NotNull>
+ </column>
+ <column id="44" parent="8" name="notePosition">
<Position>4</Position>
<DataType>INTEGER|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="32" parent="7" name="prefix">
+ <column id="45" parent="8" name="prefix">
<Position>5</Position>
<DataType>TEXT|0s</DataType>
</column>
- <column id="33" parent="7" name="isExpanded">
+ <column id="46" parent="8" name="isExpanded">
<Position>6</Position>
<DataType>BOOLEAN|0s</DataType>
</column>
- <column id="34" parent="7" name="isDeleted">
+ <column id="47" parent="8" name="isDeleted">
<Position>7</Position>
<DataType>INTEGER|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="35" parent="7" name="dateModified">
+ <column id="48" parent="8" name="dateModified">
<Position>8</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="36" parent="7" name="hash">
+ <column id="49" parent="8" name="hash">
<Position>9</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <column id="37" parent="7" name="dateCreated">
+ <column id="50" parent="8" name="dateCreated">
<Position>10</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;1970-01-01T00:00:00.000Z&apos;</DefaultExpression>
</column>
- <index id="38" parent="7" name="sqlite_autoindex_branches_1">
+ <index id="51" parent="8" name="sqlite_autoindex_branches_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>branchId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="39" parent="7" name="IDX_branches_noteId_parentNoteId">
+ <index id="52" parent="8" name="IDX_branches_noteId_parentNoteId">
<ColNames>noteId
parentNoteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="40" parent="7" name="IDX_branches_noteId">
+ <index id="53" parent="8" name="IDX_branches_noteId">
<ColNames>noteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="41" parent="7" name="IDX_branches_parentNoteId">
+ <index id="54" parent="8" name="IDX_branches_parentNoteId">
<ColNames>parentNoteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="42" parent="7">
+ <key id="55" parent="8">
<ColNames>branchId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_branches_1</UnderlyingIndexName>
</key>
- <column id="43" parent="8" name="eventId">
+ <column id="56" parent="9" name="eventId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="44" parent="8" name="noteId">
+ <column id="57" parent="9" name="noteId">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
</column>
- <column id="45" parent="8" name="comment">
+ <column id="58" parent="9" name="comment">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
</column>
- <column id="46" parent="8" name="dateCreated">
+ <column id="59" parent="9" name="dateCreated">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <index id="47" parent="8" name="sqlite_autoindex_event_log_1">
+ <index id="60" parent="9" name="sqlite_autoindex_event_log_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>eventId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <key id="48" parent="8">
+ <key id="61" parent="9">
<ColNames>eventId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_event_log_1</UnderlyingIndexName>
</key>
- <column id="49" parent="9" name="imageId">
+ <column id="62" parent="10" name="imageId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="50" parent="9" name="format">
+ <column id="63" parent="10" name="format">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="51" parent="9" name="checksum">
+ <column id="64" parent="10" name="checksum">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="52" parent="9" name="name">
+ <column id="65" parent="10" name="name">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="53" parent="9" name="data">
+ <column id="66" parent="10" name="data">
<Position>5</Position>
<DataType>BLOB|0s</DataType>
</column>
- <column id="54" parent="9" name="isDeleted">
+ <column id="67" parent="10" name="isDeleted">
<Position>6</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="55" parent="9" name="dateModified">
+ <column id="68" parent="10" name="dateModified">
<Position>7</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="56" parent="9" name="dateCreated">
+ <column id="69" parent="10" name="dateCreated">
<Position>8</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="57" parent="9" name="hash">
+ <column id="70" parent="10" name="hash">
<Position>9</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <index id="58" parent="9" name="sqlite_autoindex_images_1">
+ <index id="71" parent="10" name="sqlite_autoindex_images_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>imageId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <key id="59" parent="9">
+ <key id="72" parent="10">
<ColNames>imageId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_images_1</UnderlyingIndexName>
</key>
- <column id="60" parent="10" name="labelId">
+ <column id="73" parent="11" name="labelId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="61" parent="10" name="noteId">
+ <column id="74" parent="11" name="noteId">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="62" parent="10" name="name">
+ <column id="75" parent="11" name="name">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="63" parent="10" name="value">
+ <column id="76" parent="11" name="value">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;&apos;</DefaultExpression>
</column>
- <column id="64" parent="10" name="position">
+ <column id="77" parent="11" name="position">
<Position>5</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="65" parent="10" name="dateCreated">
+ <column id="78" parent="11" name="dateCreated">
<Position>6</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="66" parent="10" name="dateModified">
+ <column id="79" parent="11" name="dateModified">
<Position>7</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="67" parent="10" name="isDeleted">
+ <column id="80" parent="11" name="isDeleted">
<Position>8</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="68" parent="10" name="hash">
+ <column id="81" parent="11" name="hash">
<Position>9</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <index id="69" parent="10" name="sqlite_autoindex_labels_1">
+ <index id="82" parent="11" name="sqlite_autoindex_labels_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>labelId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="70" parent="10" name="IDX_labels_noteId">
+ <index id="83" parent="11" name="IDX_attributes_noteId">
<ColNames>noteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="71" parent="10" name="IDX_labels_name_value">
+ <index id="84" parent="11" name="IDX_labels_noteId">
+ <ColNames>noteId</ColNames>
+ <ColumnCollations></ColumnCollations>
+ </index>
+ <index id="85" parent="11" name="IDX_attributes_name_value">
<ColNames>name
value</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="72" parent="10">
+ <index id="86" parent="11" name="IDX_labels_name_value">
+ <ColNames>name
+value</ColNames>
+ <ColumnCollations></ColumnCollations>
+ </index>
+ <index id="87" parent="11" name="IDX_attributes_value">
+ <ColNames>value</ColNames>
+ <ColumnCollations></ColumnCollations>
+ </index>
+ <key id="88" parent="11">
<ColNames>labelId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_labels_1</UnderlyingIndexName>
</key>
- <column id="73" parent="11" name="noteImageId">
+ <column id="89" parent="12" name="noteImageId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="74" parent="11" name="noteId">
+ <column id="90" parent="12" name="noteId">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="75" parent="11" name="imageId">
+ <column id="91" parent="12" name="imageId">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="76" parent="11" name="isDeleted">
+ <column id="92" parent="12" name="isDeleted">
<Position>4</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="77" parent="11" name="dateModified">
+ <column id="93" parent="12" name="dateModified">
<Position>5</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="78" parent="11" name="dateCreated">
+ <column id="94" parent="12" name="dateCreated">
<Position>6</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="79" parent="11" name="hash">
+ <column id="95" parent="12" name="hash">
<Position>7</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <index id="80" parent="11" name="sqlite_autoindex_note_images_1">
+ <index id="96" parent="12" name="sqlite_autoindex_note_images_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>noteImageId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="81" parent="11" name="IDX_note_images_noteId_imageId">
+ <index id="97" parent="12" name="IDX_note_images_noteId_imageId">
<ColNames>noteId
imageId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="82" parent="11" name="IDX_note_images_noteId">
+ <index id="98" parent="12" name="IDX_note_images_noteId">
<ColNames>noteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="83" parent="11" name="IDX_note_images_imageId">
+ <index id="99" parent="12" name="IDX_note_images_imageId">
<ColNames>imageId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="84" parent="11">
+ <key id="100" parent="12">
<ColNames>noteImageId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_note_images_1</UnderlyingIndexName>
</key>
- <column id="85" parent="12" name="noteRevisionId">
+ <column id="101" parent="13" name="noteRevisionId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="86" parent="12" name="noteId">
+ <column id="102" parent="13" name="noteId">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="87" parent="12" name="title">
+ <column id="103" parent="13" name="title">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
</column>
- <column id="88" parent="12" name="content">
+ <column id="104" parent="13" name="content">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
</column>
- <column id="89" parent="12" name="isProtected">
+ <column id="105" parent="13" name="isProtected">
<Position>5</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="90" parent="12" name="dateModifiedFrom">
+ <column id="106" parent="13" name="dateModifiedFrom">
<Position>6</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="91" parent="12" name="dateModifiedTo">
+ <column id="107" parent="13" name="dateModifiedTo">
<Position>7</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="92" parent="12" name="type">
+ <column id="108" parent="13" name="type">
<Position>8</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;&apos;</DefaultExpression>
</column>
- <column id="93" parent="12" name="mime">
+ <column id="109" parent="13" name="mime">
<Position>9</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;&apos;</DefaultExpression>
</column>
- <column id="94" parent="12" name="hash">
+ <column id="110" parent="13" name="hash">
<Position>10</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <index id="95" parent="12" name="sqlite_autoindex_note_revisions_1">
+ <index id="111" parent="13" name="sqlite_autoindex_note_revisions_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>noteRevisionId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="96" parent="12" name="IDX_note_revisions_noteId">
+ <index id="112" parent="13" name="IDX_note_revisions_noteId">
<ColNames>noteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="97" parent="12" name="IDX_note_revisions_dateModifiedFrom">
+ <index id="113" parent="13" name="IDX_note_revisions_dateModifiedFrom">
<ColNames>dateModifiedFrom</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="98" parent="12" name="IDX_note_revisions_dateModifiedTo">
+ <index id="114" parent="13" name="IDX_note_revisions_dateModifiedTo">
<ColNames>dateModifiedTo</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="99" parent="12">
+ <key id="115" parent="13">
<ColNames>noteRevisionId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_note_revisions_1</UnderlyingIndexName>
</key>
- <column id="100" parent="13" name="noteId">
+ <column id="116" parent="14" name="noteId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="101" parent="13" name="title">
+ <column id="117" parent="14" name="title">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;unnamed&quot;</DefaultExpression>
</column>
- <column id="102" parent="13" name="content">
+ <column id="118" parent="14" name="content">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <column id="103" parent="13" name="isProtected">
+ <column id="119" parent="14" name="isProtected">
<Position>4</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="104" parent="13" name="isDeleted">
+ <column id="120" parent="14" name="isDeleted">
<Position>5</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="105" parent="13" name="dateCreated">
+ <column id="121" parent="14" name="dateCreated">
<Position>6</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="106" parent="13" name="dateModified">
+ <column id="122" parent="14" name="dateModified">
<Position>7</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="107" parent="13" name="type">
+ <column id="123" parent="14" name="type">
<Position>8</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;text&apos;</DefaultExpression>
</column>
- <column id="108" parent="13" name="mime">
+ <column id="124" parent="14" name="mime">
<Position>9</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;text/html&apos;</DefaultExpression>
</column>
- <column id="109" parent="13" name="hash">
+ <column id="125" parent="14" name="hash">
<Position>10</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <index id="110" parent="13" name="sqlite_autoindex_notes_1">
+ <index id="126" parent="14" name="sqlite_autoindex_notes_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>noteId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="111" parent="13" name="IDX_notes_type">
+ <index id="127" parent="14" name="IDX_notes_type">
<ColNames>type</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="112" parent="13">
+ <key id="128" parent="14">
<ColNames>noteId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_notes_1</UnderlyingIndexName>
</key>
- <column id="113" parent="14" name="name">
+ <column id="129" parent="15" name="name">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="114" parent="14" name="value">
+ <column id="130" parent="15" name="value">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
</column>
- <column id="115" parent="14" name="dateModified">
+ <column id="131" parent="15" name="dateModified">
<Position>3</Position>
<DataType>INT|0s</DataType>
</column>
- <column id="116" parent="14" name="isSynced">
+ <column id="132" parent="15" name="isSynced">
<Position>4</Position>
<DataType>INTEGER|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="117" parent="14" name="hash">
+ <column id="133" parent="15" name="hash">
<Position>5</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <column id="118" parent="14" name="dateCreated">
+ <column id="134" parent="15" name="dateCreated">
<Position>6</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&apos;1970-01-01T00:00:00.000Z&apos;</DefaultExpression>
</column>
- <index id="119" parent="14" name="sqlite_autoindex_options_1">
+ <index id="135" parent="15" name="sqlite_autoindex_options_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>name</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <key id="120" parent="14">
+ <key id="136" parent="15">
<ColNames>name</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_options_1</UnderlyingIndexName>
</key>
- <column id="121" parent="15" name="branchId">
+ <column id="137" parent="16" name="branchId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="122" parent="15" name="notePath">
+ <column id="138" parent="16" name="notePath">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="123" parent="15" name="hash">
+ <column id="139" parent="16" name="hash">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <column id="124" parent="15" name="dateCreated">
+ <column id="140" parent="16" name="dateCreated">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="125" parent="15" name="isDeleted">
+ <column id="141" parent="16" name="isDeleted">
<Position>5</Position>
<DataType>INT|0s</DataType>
</column>
- <index id="126" parent="15" name="sqlite_autoindex_recent_notes_1">
+ <index id="142" parent="16" name="sqlite_autoindex_recent_notes_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>branchId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <key id="127" parent="15">
+ <key id="143" parent="16">
<ColNames>branchId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_recent_notes_1</UnderlyingIndexName>
</key>
- <column id="128" parent="16" name="relationId">
+ <column id="144" parent="17" name="relationId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="129" parent="16" name="sourceNoteId">
+ <column id="145" parent="17" name="sourceNoteId">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="130" parent="16" name="name">
+ <column id="146" parent="17" name="name">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="131" parent="16" name="targetNoteId">
+ <column id="147" parent="17" name="targetNoteId">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="132" parent="16" name="position">
+ <column id="148" parent="17" name="position">
<Position>5</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>0</DefaultExpression>
</column>
- <column id="133" parent="16" name="dateCreated">
+ <column id="149" parent="17" name="dateCreated">
<Position>6</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="134" parent="16" name="dateModified">
+ <column id="150" parent="17" name="dateModified">
<Position>7</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="135" parent="16" name="isDeleted">
+ <column id="151" parent="17" name="isDeleted">
<Position>8</Position>
<DataType>INT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="136" parent="16" name="hash">
+ <column id="152" parent="17" name="hash">
<Position>9</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
<DefaultExpression>&quot;&quot;</DefaultExpression>
</column>
- <column id="137" parent="16" name="isInheritable">
+ <column id="153" parent="17" name="isInheritable">
<Position>10</Position>
<DataType>int|0s</DataType>
<DefaultExpression>0</DefaultExpression>
</column>
- <index id="138" parent="16" name="sqlite_autoindex_relations_1">
+ <index id="154" parent="17" name="sqlite_autoindex_relations_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>relationId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="139" parent="16" name="IDX_relation_sourceNoteId">
+ <index id="155" parent="17" name="IDX_relation_sourceNoteId">
<ColNames>sourceNoteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <index id="140" parent="16" name="IDX_relation_targetNoteId">
+ <index id="156" parent="17" name="IDX_relation_targetNoteId">
<ColNames>targetNoteId</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="141" parent="16">
+ <key id="157" parent="17">
<ColNames>relationId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_relations_1</UnderlyingIndexName>
</key>
- <column id="142" parent="17" name="sourceId">
+ <column id="158" parent="18" name="sourceId">
<Position>1</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="143" parent="17" name="dateCreated">
+ <column id="159" parent="18" name="dateCreated">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <index id="144" parent="17" name="sqlite_autoindex_source_ids_1">
+ <index id="160" parent="18" name="sqlite_autoindex_source_ids_1">
<NameSurrogate>1</NameSurrogate>
<ColNames>sourceId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <key id="145" parent="17">
+ <key id="161" parent="18">
<ColNames>sourceId</ColNames>
<Primary>1</Primary>
<UnderlyingIndexName>sqlite_autoindex_source_ids_1</UnderlyingIndexName>
</key>
- <column id="146" parent="18" name="type">
+ <column id="162" parent="19" name="type">
<Position>1</Position>
<DataType>text|0s</DataType>
</column>
- <column id="147" parent="18" name="name">
+ <column id="163" parent="19" name="name">
<Position>2</Position>
<DataType>text|0s</DataType>
</column>
- <column id="148" parent="18" name="tbl_name">
+ <column id="164" parent="19" name="tbl_name">
<Position>3</Position>
<DataType>text|0s</DataType>
</column>
- <column id="149" parent="18" name="rootpage">
+ <column id="165" parent="19" name="rootpage">
<Position>4</Position>
<DataType>integer|0s</DataType>
</column>
- <column id="150" parent="18" name="sql">
+ <column id="166" parent="19" name="sql">
<Position>5</Position>
<DataType>text|0s</DataType>
</column>
- <column id="151" parent="19" name="name">
+ <column id="167" parent="20" name="name">
<Position>1</Position>
</column>
- <column id="152" parent="19" name="seq">
+ <column id="168" parent="20" name="seq">
<Position>2</Position>
</column>
- <column id="153" parent="20" name="id">
+ <column id="169" parent="21" name="id">
<Position>1</Position>
<DataType>INTEGER|0s</DataType>
<NotNull>1</NotNull>
<SequenceIdentity>1</SequenceIdentity>
</column>
- <column id="154" parent="20" name="entityName">
+ <column id="170" parent="21" name="entityName">
<Position>2</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="155" parent="20" name="entityId">
+ <column id="171" parent="21" name="entityId">
<Position>3</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="156" parent="20" name="sourceId">
+ <column id="172" parent="21" name="sourceId">
<Position>4</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <column id="157" parent="20" name="syncDate">
+ <column id="173" parent="21" name="syncDate">
<Position>5</Position>
<DataType>TEXT|0s</DataType>
<NotNull>1</NotNull>
</column>
- <index id="158" parent="20" name="IDX_sync_entityName_entityId">
+ <index id="174" parent="21" name="IDX_sync_entityName_entityId">
<ColNames>entityName
entityId</ColNames>
<ColumnCollations></ColumnCollations>
<Unique>1</Unique>
</index>
- <index id="159" parent="20" name="IDX_sync_syncDate">
+ <index id="175" parent="21" name="IDX_sync_syncDate">
<ColNames>syncDate</ColNames>
<ColumnCollations></ColumnCollations>
</index>
- <key id="160" parent="20">
+ <key id="176" parent="21">
<ColNames>id</ColNames>
<Primary>1</Primary>
</key>
diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.js
new file mode 100644
index 0000000000..263887c2ad
--- /dev/null
+++ b/src/public/javascripts/dialogs/attributes.js
@@ -0,0 +1,239 @@
+import noteDetailService from '../services/note_detail.js';
+import server from '../services/server.js';
+import infoService from "../services/info.js";
+
+const $dialog = $("#attributes-dialog");
+const $saveAttributesButton = $("#save-attributes-button");
+const $attributesBody = $('#attributes-table tbody');
+
+const attributesModel = new AttributesModel();
+
+function AttributesModel() {
+ const self = this;
+
+ this.attributes = ko.observableArray();
+
+ this.availableTypes = [
+ { text: "Label", value: "label" },
+ { text: "Label definition", value: "definition" },
+ { text: "Relation", value: "relation" }
+ ];
+
+ this.updateAttributePositions = function() {
+ let position = 0;
+
+ // we need to update positions by searching in the DOM, because order of the
+ // attributes in the viewmodel (self.attributes()) stays the same
+ $attributesBody.find('input[name="position"]').each(function() {
+ const attribute = self.getTargetAttribute(this);
+
+ attribute().position = position++;
+ });
+ };
+
+ this.loadAttributes = async function() {
+ const noteId = noteDetailService.getCurrentNoteId();
+
+ const attributes = await server.get('notes/' + noteId + '/attributes');
+
+ self.attributes(attributes.map(ko.observable));
+
+ addLastEmptyRow();
+
+ // attribute might not be rendered immediatelly so could not focus
+ setTimeout(() => $(".attribute-name:last").focus(), 100);
+
+ $attributesBody.sortable({
+ handle: '.handle',
+ containment: $attributesBody,
+ update: this.updateAttributePositions
+ });
+ };
+
+ this.deleteAttribute = function(data, event) {
+ const attribute = self.getTargetAttribute(event.target);
+ const attributeData = attribute();
+
+ if (attributeData) {
+ attributeData.isDeleted = 1;
+
+ attribute(attributeData);
+
+ addLastEmptyRow();
+ }
+ };
+
+ function isValid() {
+ for (let attributes = self.attributes(), i = 0; i < attributes.length; i++) {
+ if (self.isEmptyName(i)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ this.save = async function() {
+ // we need to defocus from input (in case of enter-triggered save) because value is updated
+ // on blur event (because of conflict with jQuery UI Autocomplete). Without this, input would
+ // stay in focus, blur wouldn't be triggered and change wouldn't be updated in the viewmodel.
+ $saveAttributesButton.focus();
+
+ if (!isValid()) {
+ alert("Please fix all validation errors and try saving again.");
+ return;
+ }
+
+ self.updateAttributePositions();
+
+ const noteId = noteDetailService.getCurrentNoteId();
+
+ const attributesToSave = self.attributes()
+ .map(attribute => attribute())
+ .filter(attribute => attribute.attributeId !== "" || attribute.name !== "");
+
+ const attributes = await server.put('notes/' + noteId + '/attributes', attributesToSave);
+
+ self.attributes(attributes.map(ko.observable));
+
+ addLastEmptyRow();
+
+ infoService.showMessage("Attributes have been saved.");
+
+ noteDetailService.loadAttributeList();
+ };
+
+ function addLastEmptyRow() {
+ const attributes = self.attributes().filter(attr => attr().isDeleted === 0);
+ const last = attributes.length === 0 ? null : attributes[attributes.length - 1]();
+
+ if (!last || last.name.trim() !== "" || last.value !== "") {
+ self.attributes.push(ko.observable({
+ attributeId: '',
+ type: 'label',
+ name: '',
+ value: '',
+ isDeleted: 0,
+ position: 0
+ }));
+ }
+ }
+
+ this.attributeChanged = function (data, event) {
+ addLastEmptyRow();
+
+ const attribute = self.getTargetAttribute(event.target);
+
+ attribute.valueHasMutated();
+ };
+
+ this.isNotUnique = function(index) {
+ const cur = self.attributes()[index]();
+
+ if (cur.name.trim() === "") {
+ return false;
+ }
+
+ for (let attributes = self.attributes(), i = 0; i < attributes.length; i++) {
+ const attribute = attributes[i]();
+
+ if (index !== i && cur.name === attribute.name) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ this.isEmptyName = function(index) {
+ const cur = self.attributes()[index]();
+
+ return cur.name.trim() === "" && (cur.attributeId !== "" || cur.value !== "");
+ };
+
+ this.getTargetAttribute = function(target) {
+ const context = ko.contextFor(target);
+ const index = context.$index();
+
+ return self.attributes()[index];
+ }
+}
+
+async function showDialog() {
+ glob.activeDialog = $dialog;
+
+ await attributesModel.loadAttributes();
+
+ $dialog.dialog({
+ modal: true,
+ width: 950,
+ height: 500
+ });
+}
+
+ko.applyBindings(attributesModel, $dialog[0]);
+
+$dialog.on('focus', '.attribute-name', function (e) {
+ if (!$(this).hasClass("ui-autocomplete-input")) {
+ $(this).autocomplete({
+ source: async (request, response) => {
+ const attribute = attributesModel.getTargetAttribute(this);
+ const type = attribute().type === 'relation' ? 'relation' : 'label';
+ const names = await server.get('attributes/names/?type=' + type + '&query=' + encodeURIComponent(request.term));
+ const result = names.map(name => {
+ return {
+ label: name,
+ value: name
+ }
+ });
+
+ if (result.length > 0) {
+ response(result);
+ }
+ else {
+ response([{
+ label: "No results",
+ value: "No results"
+ }]);
+ }
+ },
+ minLength: 0
+ });
+ }
+
+ $(this).autocomplete("search", $(this).val());
+});
+
+$dialog.on('focus', '.attribute-value', async function (e) {
+ if (!$(this).hasClass("ui-autocomplete-input")) {
+ const attributeName = $(this).parent().parent().find('.attribute-name').val();
+
+ if (attributeName.trim() === "") {
+ return;
+ }
+
+ const attributeValues = await server.get('attributes/values/' + encodeURIComponent(attributeName));
+
+ if (attributeValues.length === 0) {
+ return;
+ }
+
+ $(this).autocomplete({
+ // shouldn't be required and autocomplete should just accept array of strings, but that fails
+ // because we have overriden filter() function in autocomplete.js
+ source: attributeValues.map(attribute => {
+ return {
+ attribute: attribute,
+ value: attribute
+ }
+ }),
+ minLength: 0
+ });
+ }
+
+ $(this).autocomplete("search", $(this).val());
+});
+
+export default {
+ showDialog
+};
\ No newline at end of file
diff --git a/src/public/javascripts/services/bootstrap.js b/src/public/javascripts/services/bootstrap.js
index 84273e4790..15236b2221 100644
--- a/src/public/javascripts/services/bootstrap.js
+++ b/src/public/javascripts/services/bootstrap.js
@@ -1,6 +1,7 @@
import addLinkDialog from '../dialogs/add_link.js';
import jumpToNoteDialog from '../dialogs/jump_to_note.js';
import labelsDialog from '../dialogs/labels.js';
+import attributesDialog from '../dialogs/attributes.js';
import noteRevisionsDialog from '../dialogs/note_revisions.js';
import noteSourceDialog from '../dialogs/note_source.js';
import recentChangesDialog from '../dialogs/recent_changes.js';
diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.js
index d25f79785d..0d11d92aec 100644
--- a/src/public/javascripts/services/entrypoints.js
+++ b/src/public/javascripts/services/entrypoints.js
@@ -11,6 +11,7 @@ import noteSourceDialog from "../dialogs/note_source.js";
import recentChangesDialog from "../dialogs/recent_changes.js";
import sqlConsoleDialog from "../dialogs/sql_console.js";
import searchNotesService from "./search_notes.js";
+import attributesDialog from "../dialogs/attributes.js";
import labelsDialog from "../dialogs/labels.js";
import relationsDialog from "../dialogs/relations.js";
import protectedSessionService from "./protected_session.js";
@@ -38,6 +39,9 @@ function registerEntrypoints() {
$("#toggle-search-button").click(searchNotesService.toggleSearch);
utils.bindShortcut('ctrl+s', searchNotesService.toggleSearch);
+ $(".show-attributes-button").click(attributesDialog.showDialog);
+ utils.bindShortcut('alt+a', attributesDialog.showDialog);
+
$(".show-labels-button").click(labelsDialog.showDialog);
utils.bindShortcut('alt+l', labelsDialog.showDialog);
diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.js
index 174eb05ebf..f582070ec8 100644
--- a/src/routes/api/attributes.js
+++ b/src/routes/api/attributes.js
@@ -42,18 +42,11 @@ async function updateNoteAttributes(req) {
return await repository.getEntities("SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ? ORDER BY position, dateCreated", [noteId]);
}
-async function getAllAttributeNames() {
- const names = await sql.getColumn("SELECT DISTINCT name FROM attributes WHERE isDeleted = 0");
+async function getAttributeNames(req) {
+ const type = req.query.type;
+ const query = req.query.query;
- for (const attribute of attributeService.BUILTIN_ATTRIBUTES) {
- if (!names.includes(attribute)) {
- names.push(attribute);
- }
- }
-
- names.sort();
-
- return names;
+ return attributeService.getAttributeNames(type, query);
}
async function getValuesForAttribute(req) {
@@ -65,6 +58,6 @@ async function getValuesForAttribute(req) {
module.exports = {
getNoteAttributes,
updateNoteAttributes,
- getAllAttributeNames,
+ getAttributeNames,
getValuesForAttribute
};
\ No newline at end of file
diff --git a/src/routes/routes.js b/src/routes/routes.js
index 1cc74a817f..f492b12dc8 100644
--- a/src/routes/routes.js
+++ b/src/routes/routes.js
@@ -136,7 +136,7 @@ function register(app) {
apiRoute(GET, '/api/notes/:noteId/attributes', attributesRoute.getNoteAttributes);
apiRoute(PUT, '/api/notes/:noteId/attributes', attributesRoute.updateNoteAttributes);
- apiRoute(GET, '/api/attributes/names', attributesRoute.getAllAttributeNames);
+ apiRoute(GET, '/api/attributes/names', attributesRoute.getAttributeNames);
apiRoute(GET, '/api/attributes/values/:attributeName', attributesRoute.getValuesForAttribute);
apiRoute(GET, '/api/notes/:noteId/labels', labelsRoute.getNoteLabels);
diff --git a/src/services/attributes.js b/src/services/attributes.js
index 069df17ba4..0ece703c69 100644
--- a/src/services/attributes.js
+++ b/src/services/attributes.js
@@ -1,18 +1,25 @@
"use strict";
const repository = require('./repository');
+const sql = require('./sql');
+const utils = require('./utils');
const Attribute = require('../entities/attribute');
const BUILTIN_ATTRIBUTES = [
- 'disableVersioning',
- 'calendarRoot',
- 'archived',
- 'excludeFromExport',
- 'run',
- 'manualTransactionHandling',
- 'disableInclusion',
- 'appCss',
- 'hideChildrenOverview'
+ // label names
+ { type: 'label', name: 'disableVersioning' },
+ { type: 'label', name: 'calendarRoot' },
+ { type: 'label', name: 'archived' },
+ { type: 'label', name: 'excludeFromExport' },
+ { type: 'label', name: 'run' },
+ { type: 'label', name: 'manualTransactionHandling' },
+ { type: 'label', name: 'disableInclusion' },
+ { type: 'label', name: 'appCss' },
+ { type: 'label', name: 'hideChildrenOverview' },
+
+ // relation names
+ { type: 'relation', name: 'runOnNoteView' },
+ { type: 'relation', name: 'runOnNoteTitleChange' }
];
async function getNotesWithAttribute(name, value) {
@@ -44,9 +51,29 @@ async function createAttribute(noteId, name, value = "") {
}).save();
}
+async function getAttributeNames(type, nameLike) {
+ const names = await sql.getColumn(
+ `SELECT DISTINCT name
+ FROM attributes
+ WHERE isDeleted = 0
+ AND type = ?
+ AND name LIKE '%${utils.sanitizeSql(nameLike)}%'`, [ type ]);
+
+ for (const attribute of BUILTIN_ATTRIBUTES) {
+ if (attribute.type === type && !names.includes(attribute.name)) {
+ names.push(attribute.name);
+ }
+ }
+
+ names.sort();
+
+ return names;
+}
+
module.exports = {
getNotesWithAttribute,
getNoteWithAttribute,
createAttribute,
+ getAttributeNames,
BUILTIN_ATTRIBUTES
};
\ No newline at end of file
diff --git a/src/views/index.ejs b/src/views/index.ejs
index d7a6f68984..b62f508201 100644
--- a/src/views/index.ejs
+++ b/src/views/index.ejs
@@ -169,6 +169,7 @@
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a id="show-note-revisions-button">Note revisions</a></li>
+ <li><a class="show-attributes-button"><kbd>Alt+A</kbd> Attributes</a></li>
<li><a class="show-labels-button"><kbd>Alt+L</kbd> Labels</a></li>
<li><a class="show-relations-button"><kbd>Alt+R</kbd> Relations</a></li>
<li><a id="show-source-button">HTML source</a></li>
@@ -554,6 +555,53 @@
<textarea id="note-source" readonly="readonly"></textarea>
</div>
+ <div id="attributes-dialog" title="Note attributes" style="display: none; padding: 20px;">
+ <form data-bind="submit: save">
+ <div style="text-align: center">
+ <button class="btn btn-large" style="width: 200px;" id="save-attributes-button" type="submit">Save changes <kbd>enter</kbd></button>
+ </div>
+
+ <div style="height: 97%; overflow: auto">
+ <table id="attributes-table" class="table">
+ <thead>
+ <tr>
+ <th></th>
+ <th>ID</th>
+ <th>Name</th>
+ <th>Value</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody data-bind="foreach: attributes">
+ <tr data-bind="if: isDeleted == 0">
+ <td class="handle">
+ <span class="glyphicon glyphicon-resize-vertical"></span>
+ <input type="hidden" name="position" data-bind="value: position"/>
+ </td>
+ <!-- ID column has specific width because if it's empty its size can be deformed when dragging -->
+ <td data-bind="text: attributeId" style="min-width: 10em; font-size: smaller;"></td>
+ <td>
+ <select data-bind="options: $root.availableTypes, optionsText: 'text', optionsValue: 'value', value: type"></select>
+ </td>
+ <td>
+ <!-- Change to valueUpdate: blur is necessary because jQuery UI autocomplete hijacks change event -->
+ <input type="text" class="attribute-name form-control" data-bind="value: name, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }"/>
+ <div style="color: yellowgreen" data-bind="if: $parent.isNotUnique($index())"><span class="glyphicon glyphicon-info-sign"></span> Duplicate attribute.</div>
+ <div style="color: red" data-bind="if: $parent.isEmptyName($index())">Attribute name can't be empty.</div>
+ </td>
+ <td>
+ <input type="text" class="attribute-value form-control" data-bind="value: value, valueUpdate: 'blur', event: { blur: $parent.attributeChanged }" style="width: 300px"/>
+ </td>
+ <td title="Delete" style="padding: 13px; cursor: pointer;">
+ <span class="glyphicon glyphicon-trash" data-bind="click: $parent.deleteAttribute"></span>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </form>
+ </div>
+
<div id="labels-dialog" title="Note labels" style="display: none; padding: 20px;">
<form data-bind="submit: save">
<div style="text-align: center">