Commit 4931a836 authored by Fatih Acet's avatar Fatih Acet

Improvements to simplify vue template.

parent 9d70a4ba
...@@ -48,21 +48,23 @@ class window.MergeConflictResolver extends Vue ...@@ -48,21 +48,23 @@ class window.MergeConflictResolver extends Vue
decorateData: (data) -> decorateData: (data) ->
headHeaderText = 'HEAD//our changes'
originHeaderText = 'origin//their changes'
for file in data.files for file in data.files
file.parallelLines = { left: [], right: [] } file.parallelLines = { left: [], right: [] }
file.inlineLines = [] file.inlineLines = []
file.shortCommitSha = file.commit_sha.slice 0, 7
currentLineType = 'old' currentLineType = 'old'
for section in file.sections for section in file.sections
{ conflict, lines, id } = section { conflict, lines, id } = section
if conflict if conflict
header = { lineType: 'header', id } file.parallelLines.left.push { isHeader: yes, id, text: headHeaderText, cssClass: 'head' }
file.parallelLines.left.push header file.parallelLines.right.push { isHeader: yes, id, text: originHeaderText, cssClass: 'origin' }
file.parallelLines.right.push header
header.type = 'old' file.inlineLines.push { isHeader: yes, id, text: headHeaderText, type: 'old', cssClass: 'head' }
file.inlineLines.push header
for line in lines for line in lines
if line.type in ['new', 'old'] and currentLineType isnt line.type if line.type in ['new', 'old'] and currentLineType isnt line.type
...@@ -71,14 +73,15 @@ class window.MergeConflictResolver extends Vue ...@@ -71,14 +73,15 @@ class window.MergeConflictResolver extends Vue
file.inlineLines.push { lineType: 'emptyLine', text: '<span> </span>' } file.inlineLines.push { lineType: 'emptyLine', text: '<span> </span>' }
line.conflict = conflict line.conflict = conflict
line.cssClass = if line.type is 'old' then 'head' else if line.type is 'new' then 'origin' else ''
file.inlineLines.push line file.inlineLines.push line
if conflict if conflict
if line.type is 'old' if line.type is 'old'
line = { lineType: 'conflict', lineNumber: line.old_line, text: line.text } line = { lineType: 'conflict', lineNumber: line.old_line, text: line.text, cssClass: 'head' }
file.parallelLines.left.push line file.parallelLines.left.push line
else if line.type is 'new' else if line.type is 'new'
line = { lineType: 'conflict', lineNumber: line.new_line, text: line.text } line = { lineType: 'conflict', lineNumber: line.new_line, text: line.text, cssClass: 'origin' }
file.parallelLines.right.push line file.parallelLines.right.push line
else else
console.log 'unhandled line type...', line console.log 'unhandled line type...', line
...@@ -87,9 +90,8 @@ class window.MergeConflictResolver extends Vue ...@@ -87,9 +90,8 @@ class window.MergeConflictResolver extends Vue
file.parallelLines.right.push { lineType: 'context', lineNumber: line.new_line, text: line.text } file.parallelLines.right.push { lineType: 'context', lineNumber: line.new_line, text: line.text }
if conflict if conflict
file.inlineLines.push { lineType: 'header', id, type: 'new' } file.inlineLines.push { isHeader: yes, id, type: 'new', text: originHeaderText, cssClass: 'origin' }
console.log data
return data return data
......
...@@ -31,23 +31,23 @@ ...@@ -31,23 +31,23 @@
%a %a
%span {{file.new_path}} %span {{file.new_path}}
.file-actions .file-actions
%a.btn.btn-sm View file @{{file.commit_sha.slice(0, 7)}} %a.btn.btn-sm View file @{{file.shortCommitSha}}
.diff-content.diff-wrap-lines .diff-content.diff-wrap-lines
.diff-wrap-lines.code.file-content.js-syntax-highlight.white .diff-wrap-lines.code.file-content.js-syntax-highlight.white
%table{"v-for" => "(key, group) in file.parallelLines"} %table{"v-for" => "(key, group) in file.parallelLines"}
%tr.line_holder.parallel{ | %tr.line_holder.parallel{"v-for" => "line in group", ":class" => "line.cssClass"}
"v-for" => "line in group", |
":class" => "line.lineType != 'context' && (key == 'left' ? 'head' : 'origin')"}
%td.diff-line-num.header{"v-if" => "line.lineType == 'header'"} %template{"v-if" => "line.isHeader"}
%td.line_content.header{"v-if" => "line.lineType == 'header'"} %td.diff-line-num.header
%strong {{key == 'left' ? 'HEAD//our changes' : 'origin//their changes'}} %td.line_content.header
%strong {{line.text}}
%button.btn{"@click" => "handleSelected(line.id, line.lineType)"} Use this %button.btn{"@click" => "handleSelected(line.id, line.lineType)"} Use this
%td.diff-line-num.old_line{"v-if" => "line.lineType != 'header'"} %template{"v-if" => "!line.isHeader"}
%td.diff-line-num.old_line
{{line.lineNumber}} {{line.lineNumber}}
%td.line_content{"v-if" => "line.lineType != 'header'"} %td.line_content
{{line.text}} {{line.text}}
...@@ -58,16 +58,14 @@ ...@@ -58,16 +58,14 @@
%a %a
%span {{file.new_path}} %span {{file.new_path}}
.file-actions .file-actions
%a.btn.btn-sm View file @{{file.commit_sha.slice(0, 7)}} %a.btn.btn-sm View file @{{file.shortCommitSha}}
.diff-content.diff-wrap-lines .diff-content.diff-wrap-lines
.diff-wrap-lines.code.file-content.js-syntax-highlight.white .diff-wrap-lines.code.file-content.js-syntax-highlight.white
%table %table
%tr.line_holder{ | %tr.line_holder{"v-for" => "line in file.inlineLines", ":class" => "line.cssClass"}
"v-for" => "line in file.inlineLines", |
":class" => "line.type == 'old' ? 'head' : line.type == 'new' ? 'origin' : ''"}
%template{"v-if" => "line.lineType != 'header'"} %template{"v-if" => "!line.isHeader"}
%td.diff-line-num.old_line %td.diff-line-num.old_line
%a {{line.old_line}} %a {{line.old_line}}
%td.diff-line-num.new_line %td.diff-line-num.new_line
...@@ -75,9 +73,9 @@ ...@@ -75,9 +73,9 @@
%td.line_content %td.line_content
{{{line.text}}} {{{line.text}}}
%template{"v-if" => "line.lineType == 'header'"} %template{"v-if" => "line.isHeader"}
%td.diff-line-num.header %td.diff-line-num.header
%td.diff-line-num.header %td.diff-line-num.header
%td.line_content.header %td.line_content.header
%strong {{line.type == 'old' ? 'HEAD//our changes' : 'origin//their changes'}} %strong {{line.text}}
%button.btn{"@click" => "handleSelected(line.id, line.type)"} Use this %button.btn{"@click" => "handleSelected(line.id, line.type)"} Use this
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment