Initial prettier formatted files

This commit is contained in:
Dmitry Yankowski
2020-02-24 13:44:50 -05:00
parent 1543c990ca
commit 777e629b3d
83 changed files with 18556 additions and 19258 deletions

View File

@@ -11,28 +11,28 @@
<style scoped lang="scss"></style>
<script>
import typelink from "./typelink";
import typelink from './typelink'
export default {
components: {
typelink: typelink
typelink: typelink,
},
props: {
gqlArg: Object
gqlArg: Object,
},
computed: {
argName() {
return this.gqlArg.name;
return this.gqlArg.name
},
argType() {
return this.gqlArg.type;
}
return this.gqlArg.type
},
},
methods: {
jumpCallback(typeName) {}
}
};
jumpCallback(typeName) {},
},
}
</script>

View File

@@ -6,10 +6,7 @@
(
<span v-for="(field, index) in fieldArgs" :key="index">
{{ field.name }}:
<typelink
:gqlType="field.type"
:jumpTypeCallback="jumpTypeCallback"
/>
<typelink :gqlType="field.type" :jumpTypeCallback="jumpTypeCallback" />
<span v-if="index !== fieldArgs.length - 1">
,
</span>
@@ -23,7 +20,7 @@
</div>
<div class="field-deprecated" v-if="gqlField.isDeprecated">
{{ $t("deprecated") }}
{{ $t('deprecated') }}
</div>
</div>
</template>
@@ -53,16 +50,16 @@
</style>
<script>
import typelink from "./typelink";
import typelink from './typelink'
export default {
components: {
typelink: typelink
typelink: typelink,
},
props: {
gqlField: Object,
jumpTypeCallback: Function
jumpTypeCallback: Function,
},
computed: {
@@ -71,23 +68,21 @@ export default {
return (
acc +
`${arg.name}: ${arg.type.toString()}${
index !== this.gqlField.args.length - 1 ? ", " : ""
index !== this.gqlField.args.length - 1 ? ', ' : ''
}`
);
}, "");
const argsString = args.length > 0 ? `(${args})` : "";
return `${
this.gqlField.name
}${argsString}: ${this.gqlField.type.toString()}`;
)
}, '')
const argsString = args.length > 0 ? `(${args})` : ''
return `${this.gqlField.name}${argsString}: ${this.gqlField.type.toString()}`
},
fieldName() {
return this.gqlField.name;
return this.gqlField.name
},
fieldArgs() {
return this.gqlField.args || [];
}
}
};
return this.gqlField.args || []
},
},
}
</script>

View File

@@ -3,86 +3,79 @@
</template>
<script>
const DEFAULT_THEME = "twilight";
const DEFAULT_THEME = 'twilight'
import ace from "ace-builds";
import * as gql from "graphql";
import { getAutocompleteSuggestions } from "graphql-language-service-interface";
import "ace-builds/webpack-resolver";
import "ace-builds/src-noconflict/ext-language_tools";
import debounce from "../../functions/utils/debounce";
import ace from 'ace-builds'
import * as gql from 'graphql'
import { getAutocompleteSuggestions } from 'graphql-language-service-interface'
import 'ace-builds/webpack-resolver'
import 'ace-builds/src-noconflict/ext-language_tools'
import debounce from '../../functions/utils/debounce'
export default {
props: {
value: {
type: String,
default: ""
default: '',
},
theme: {
type: String,
required: false
required: false,
},
lang: {
type: String,
default: "json"
default: 'json',
},
options: {
type: Object,
default: {}
}
default: {},
},
},
data() {
return {
editor: null,
cacheValue: "",
validationSchema: null
};
cacheValue: '',
validationSchema: null,
}
},
watch: {
value(value) {
if (value !== this.cacheValue) {
this.editor.session.setValue(value, 1);
this.cacheValue = value;
this.editor.session.setValue(value, 1)
this.cacheValue = value
}
},
theme() {
this.editor.setTheme(`ace/theme/${this.defineTheme()}`);
this.editor.setTheme(`ace/theme/${this.defineTheme()}`)
},
lang(value) {
this.editor.getSession().setMode(`ace/mode/${value}`);
this.editor.getSession().setMode(`ace/mode/${value}`)
},
options(value) {
this.editor.setOptions(value);
}
this.editor.setOptions(value)
},
},
mounted() {
let langTools = ace.require("ace/ext/language_tools");
let langTools = ace.require('ace/ext/language_tools')
const editor = ace.edit(this.$refs.editor, {
theme: `ace/theme/${this.defineTheme()}`,
mode: `ace/mode/${this.lang}`,
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
...this.options
});
...this.options,
})
const completer = {
getCompletions: (
editor,
_session,
{ row, column },
_prefix,
callback
) => {
getCompletions: (editor, _session, { row, column }, _prefix, callback) => {
if (this.validationSchema) {
const completions = getAutocompleteSuggestions(
this.validationSchema,
editor.getValue(),
{ line: row, character: column }
);
const completions = getAutocompleteSuggestions(this.validationSchema, editor.getValue(), {
line: row,
character: column,
})
callback(
null,
@@ -90,64 +83,60 @@ export default {
name: label,
value: label,
score: 1.0,
meta: detail
meta: detail,
}))
);
)
} else {
callback(null, []);
callback(null, [])
}
}
};
},
}
langTools.setCompleters([completer]);
langTools.setCompleters([completer])
if (this.value) editor.setValue(this.value, 1);
if (this.value) editor.setValue(this.value, 1)
this.editor = editor;
this.cacheValue = this.value;
this.editor = editor
this.cacheValue = this.value
editor.on("change", () => {
const content = editor.getValue();
this.$emit("input", content);
this.parseContents(content);
this.cacheValue = content;
});
editor.on('change', () => {
const content = editor.getValue()
this.$emit('input', content)
this.parseContents(content)
this.cacheValue = content
})
this.parseContents(this.value);
this.parseContents(this.value)
},
methods: {
defineTheme() {
if (this.theme) {
return this.theme;
return this.theme
} else {
return (
this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
);
return this.$store.state.postwoman.settings.THEME_ACE_EDITOR || DEFAULT_THEME
}
},
setValidationSchema(schema) {
this.validationSchema = schema;
this.parseContents(this.cacheValue);
this.validationSchema = schema
this.parseContents(this.cacheValue)
},
parseContents: debounce(function(content) {
if (content !== "") {
if (content !== '') {
try {
const doc = gql.parse(content);
const doc = gql.parse(content)
if (this.validationSchema) {
this.editor.session.setAnnotations(
gql
.validate(this.validationSchema, doc)
.map(({ locations, message }) => ({
row: locations[0].line - 1,
column: locations[0].column - 1,
text: message,
type: "error"
}))
);
gql.validate(this.validationSchema, doc).map(({ locations, message }) => ({
row: locations[0].line - 1,
column: locations[0].column - 1,
text: message,
type: 'error',
}))
)
}
} catch (e) {
this.editor.session.setAnnotations([
@@ -155,19 +144,19 @@ export default {
row: e.locations[0].line - 1,
column: e.locations[0].column - 1,
text: e.message,
type: "error"
}
]);
type: 'error',
},
])
}
} else {
this.editor.session.setAnnotations([]);
this.editor.session.setAnnotations([])
}
}, 2000)
}, 2000),
},
beforeDestroy() {
this.editor.destroy();
this.editor.container.remove();
}
};
this.editor.destroy()
this.editor.container.remove()
},
}
</script>

View File

@@ -6,7 +6,7 @@
</div>
<div v-if="gqlType.getFields">
<h5>{{ $t("fields") }}</h5>
<h5>{{ $t('fields') }}</h5>
<div v-for="field in gqlType.getFields()" :key="field.name">
<gql-field :gqlField="field" :jumpTypeCallback="jumpTypeCallback" />
</div>
@@ -33,12 +33,12 @@
<script>
export default {
components: {
"gql-field": () => import("./field")
'gql-field': () => import('./field'),
},
props: {
gqlType: {},
jumpTypeCallback: Function
}
};
jumpTypeCallback: Function,
},
}
</script>

View File

@@ -5,7 +5,7 @@
<style scoped lang="scss">
.typelink {
color: var(--ac-color);
font-family: "Roboto Mono", monospace;
font-family: 'Roboto Mono', monospace;
font-weight: 400;
cursor: pointer;
}
@@ -16,19 +16,19 @@ export default {
props: {
gqlType: null,
// (typeName: string) => void
jumpTypeCallback: Function
jumpTypeCallback: Function,
},
computed: {
typeString() {
return this.gqlType.toString();
}
return this.gqlType.toString()
},
},
methods: {
jumpToType() {
this.jumpTypeCallback(this.gqlType);
}
}
};
this.jumpTypeCallback(this.gqlType)
},
},
}
</script>