mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-22 00:07:03 +02:00
WIP: added note category, TODO: update input
This commit is contained in:
@@ -93,6 +93,10 @@
|
||||
border-radius: 5px 0 0 5px;
|
||||
}
|
||||
|
||||
.note-category {
|
||||
margin: 20px 0px;
|
||||
}
|
||||
|
||||
.comments-container {
|
||||
background: #ececec;
|
||||
padding: 1px 10px;
|
||||
|
||||
@@ -304,6 +304,22 @@ en:
|
||||
castle_type:
|
||||
# castle_type=*
|
||||
label: Type
|
||||
category:
|
||||
# 'none=*, option1=*, option2=*, option3=*, option4=*'
|
||||
label: Category
|
||||
options:
|
||||
# none=yes
|
||||
none: None
|
||||
# option1=yes
|
||||
option1: Option1
|
||||
# option2=yes
|
||||
option2: Option2
|
||||
# option3=yes
|
||||
option3: Option3
|
||||
# option4=yes
|
||||
option4: Option4
|
||||
# category field placeholder
|
||||
placeholder: Unknown
|
||||
clothes:
|
||||
# clothes=*
|
||||
label: Clothes
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
"capacity": {"key": "capacity", "type": "number", "minValue": 0, "label": "Capacity", "placeholder": "50, 100, 200..."},
|
||||
"cash_in": {"key": "cash_in", "type": "check", "label": "Cash In"},
|
||||
"castle_type": {"key": "castle_type", "type": "combo", "label": "Type"},
|
||||
"category": {"type": "radio", "keys": ["none", "option1", "option2", "option3", "option4"], "label": "Category", "placeholder": "Unknown", "strings": {"options": {"none": "None", "option1": "Option1", "option2": "Option2", "option3": "Option3", "option4": "Option4"}}},
|
||||
"clothes": {"key": "clothes", "type": "semiCombo", "label": "Clothes"},
|
||||
"club": {"key": "club", "type": "typeCombo", "label": "Type"},
|
||||
"collection_times": {"key": "collection_times", "type": "text", "label": "Collection Times"},
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"type": "radio",
|
||||
"keys": [
|
||||
"none",
|
||||
"option1",
|
||||
"option2",
|
||||
"option3",
|
||||
"option4"
|
||||
],
|
||||
"label": "Category",
|
||||
"placeholder": "Unknown",
|
||||
"strings": {
|
||||
"options": {
|
||||
"none": "None",
|
||||
"option1": "Option1",
|
||||
"option2": "Option2",
|
||||
"option3": "Option3",
|
||||
"option4": "Option4"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6375,6 +6375,31 @@
|
||||
{"key": "capacity", "description": "Capacity"},
|
||||
{"key": "cash_in", "description": "Cash In"},
|
||||
{"key": "castle_type", "description": "Type"},
|
||||
{"key": "none", "value": "none", "description": "Category"},
|
||||
{"key": "none", "value": "option1", "description": "Category"},
|
||||
{"key": "none", "value": "option2", "description": "Category"},
|
||||
{"key": "none", "value": "option3", "description": "Category"},
|
||||
{"key": "none", "value": "option4", "description": "Category"},
|
||||
{"key": "option1", "value": "none", "description": "Category"},
|
||||
{"key": "option1", "value": "option1", "description": "Category"},
|
||||
{"key": "option1", "value": "option2", "description": "Category"},
|
||||
{"key": "option1", "value": "option3", "description": "Category"},
|
||||
{"key": "option1", "value": "option4", "description": "Category"},
|
||||
{"key": "option2", "value": "none", "description": "Category"},
|
||||
{"key": "option2", "value": "option1", "description": "Category"},
|
||||
{"key": "option2", "value": "option2", "description": "Category"},
|
||||
{"key": "option2", "value": "option3", "description": "Category"},
|
||||
{"key": "option2", "value": "option4", "description": "Category"},
|
||||
{"key": "option3", "value": "none", "description": "Category"},
|
||||
{"key": "option3", "value": "option1", "description": "Category"},
|
||||
{"key": "option3", "value": "option2", "description": "Category"},
|
||||
{"key": "option3", "value": "option3", "description": "Category"},
|
||||
{"key": "option3", "value": "option4", "description": "Category"},
|
||||
{"key": "option4", "value": "none", "description": "Category"},
|
||||
{"key": "option4", "value": "option1", "description": "Category"},
|
||||
{"key": "option4", "value": "option2", "description": "Category"},
|
||||
{"key": "option4", "value": "option3", "description": "Category"},
|
||||
{"key": "option4", "value": "option4", "description": "Category"},
|
||||
{"key": "clothes", "description": "Clothes"},
|
||||
{"key": "collection_times", "description": "Collection Times"},
|
||||
{"key": "comment", "description": "Changeset Comment"},
|
||||
|
||||
Vendored
+11
@@ -1667,6 +1667,17 @@
|
||||
"castle_type": {
|
||||
"label": "Type"
|
||||
},
|
||||
"category": {
|
||||
"label": "Category",
|
||||
"placeholder": "Unknown",
|
||||
"options": {
|
||||
"none": "None",
|
||||
"option1": "Option1",
|
||||
"option2": "Option2",
|
||||
"option3": "Option3",
|
||||
"option4": "Option4"
|
||||
}
|
||||
},
|
||||
"clothes": {
|
||||
"label": "Clothes"
|
||||
},
|
||||
|
||||
@@ -39,7 +39,7 @@ export function modeAddNote(context) {
|
||||
|
||||
context
|
||||
.selectedNoteID(note.id)
|
||||
.enter(modeSelectNote(context, [note.id]).newFeature(true));
|
||||
.enter(modeSelectNote(context, note.id).newFeature(true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ export function modeDragNote(context) {
|
||||
|
||||
|
||||
mode.selectedNoteID = function() {
|
||||
if (!arguments.length) return _activeEntity ? [_activeEntity.id] : [];
|
||||
if (!arguments.length) return _activeEntity ? _activeEntity.id : [];
|
||||
// no assign
|
||||
return mode;
|
||||
};
|
||||
|
||||
@@ -129,7 +129,6 @@ export function modeSelectNote(context, selectedNoteID) {
|
||||
|
||||
context.ui().sidebar
|
||||
.hide();
|
||||
|
||||
context.selectedNoteID(null);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { dispatch as d3_dispatch } from 'd3-dispatch';
|
||||
import { select as d3_select, selectAll as d3_selectAll } from 'd3-selection';
|
||||
|
||||
import { services } from '../services';
|
||||
import { uiField } from './field';
|
||||
import { uiFormFields } from './form_fields';
|
||||
|
||||
export function uiNoteCategory(context) {
|
||||
var formFields = uiFormFields(context);
|
||||
var _note;
|
||||
var _fieldsArr;
|
||||
|
||||
function noteCategory(selection) {
|
||||
|
||||
if (!_note.isNew()) return; // don't add category
|
||||
|
||||
var initial = false;
|
||||
|
||||
if (!_fieldsArr) {
|
||||
initial = true;
|
||||
var presets = context.presets();
|
||||
|
||||
_fieldsArr = [
|
||||
uiField(context, presets.field('category'), null, { show: true, revert: false }),
|
||||
];
|
||||
|
||||
_fieldsArr.forEach(function(field) {
|
||||
field
|
||||
.on('change', change);
|
||||
});
|
||||
}
|
||||
|
||||
selection
|
||||
.append('div')
|
||||
.attr('class', 'note-category')
|
||||
.call(formFields.fieldsArr(_fieldsArr));
|
||||
|
||||
function change() {
|
||||
var val = d3_select('input[name=\'category\']:checked').property('value') || undefined;
|
||||
// NOTE: perhaps there is a better way to get value, something like ...
|
||||
// var input = d3_select(this);
|
||||
// var val = input.property('value') || undefined;
|
||||
|
||||
// store the unsaved comment with the note itself
|
||||
_note = _note.update({ newCategory: val });
|
||||
|
||||
var osm = services.osm;
|
||||
if (osm) {
|
||||
osm.replaceNote(_note); // update note cache
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
noteCategory.note = function(_) {
|
||||
if (!arguments.length) return _note;
|
||||
_note = _;
|
||||
return noteCategory;
|
||||
};
|
||||
|
||||
|
||||
return noteCategory;
|
||||
}
|
||||
@@ -11,7 +11,7 @@ export function uiNoteComments() {
|
||||
|
||||
|
||||
function noteComments(selection) {
|
||||
if (_note.isNew()) { return; }
|
||||
if (_note.isNew()) return; // don't draw .comments-container
|
||||
|
||||
var comments = selection.selectAll('.comments-container')
|
||||
.data([0]);
|
||||
|
||||
@@ -20,11 +20,13 @@ import {
|
||||
utilNoAuto,
|
||||
utilRebind
|
||||
} from '../util';
|
||||
import { uiNoteCategory } from './note_category';
|
||||
|
||||
|
||||
export function uiNoteEditor(context) {
|
||||
var dispatch = d3_dispatch('change');
|
||||
var noteComments = uiNoteComments();
|
||||
var noteCategory = uiNoteCategory(context);
|
||||
var noteHeader = uiNoteHeader();
|
||||
var _note;
|
||||
|
||||
@@ -107,6 +109,10 @@ export function uiNoteEditor(context) {
|
||||
.append('div')
|
||||
.attr('class', 'note-save save-section cf');
|
||||
|
||||
if (_note.isNew()) {
|
||||
noteSaveEnter.call(noteCategory.note(_note));
|
||||
}
|
||||
|
||||
noteSaveEnter
|
||||
.append('h4')
|
||||
.attr('class', '.note-save-header')
|
||||
|
||||
Reference in New Issue
Block a user