src_js/iconolab-bundle/src/components/mergetool/MergeTool.vue
changeset 156 e1e14766f608
parent 146 f912b591e1c1
child 539 08e2513dbc2f
equal deleted inserted replaced
153:9ed54b10ce16 156:e1e14766f608
     1 <script>
     1 <script>
     2 
     2 
     3 import Typeahead from '../typeahead/Typeahead.vue'
     3 import Typeahead from '../typeahead/Typeahead.vue'
       
     4 import DiffViewer from '../diffviewer/diffviewer.vue'
     4 
     5 
     5 export default {
     6 export default {
     6 
     7 
     7 	data () {
     8 	data () {
     8 		return {}
     9 		return {}
     9 	},
    10 	},
    10 	
    11 	
    11 	components: {
    12 	components: {
    12 		Typeahead: Typeahead
    13 		Typeahead: Typeahead,
       
    14 		'diffviewer': DiffViewer
    13 	},
    15 	},
    14 
    16 
    15 	mounted () {
    17 	mounted () {
    16 
    18 
    17 		this.targetKeyMap = {
    19 		this.targetKeyMap = {
    74 			if (!this.originalValues[key]) {
    76 			if (!this.originalValues[key]) {
    75 				this.originalValues[key] = value;
    77 				this.originalValues[key] = value;
    76 			}
    78 			}
    77 		},
    79 		},
    78 
    80 
       
    81 		showDiffviewer: function (refId, sourceId, targetKey) {
       
    82 
       
    83 			var sourceField = document.getElementById(sourceId);
       
    84 			var targetField = this.$refs[this.targetKeyMap[targetKey]];
       
    85 			var targetType = this.targetFieldTypeMap[targetKey];
       
    86 			var diffViewer = this.$refs[refId];
       
    87 			
       
    88 			if (!diffViewer) { throw new Error("The DiffViewer can't be found for " + targetKey); }
       
    89 
       
    90 			if (targetType === "input") {
       
    91 				diffViewer.showTextDiff(sourceField.value, targetField.value);
       
    92 			}
       
    93 
       
    94 			if (targetKey === "tag") {
       
    95 				var source = this.$refs[sourceId];
       
    96 				var target = this.$refs['proposal-tags'];
       
    97 				if ((source.tags.length !== 0) && (target.tags.length !== 0)) {
       
    98 					diffViewer.showTagDiff(source.tags, target.tags);
       
    99 				}
       
   100 			}
       
   101 			/* frag */
       
   102 			if ( targetKey === "frag") {
       
   103 				
       
   104 				var originalPath = targetField.getAttribute("d");
       
   105 				var modifiedPath = sourceField.getAttribute("d");
       
   106 				diffViewer.showFragmentDiff(originalPath, modifiedPath);
       
   107 			}
       
   108 
       
   109 			diffViewer.show();
       
   110 		},
       
   111 
       
   112 
    79 		hightlightSource: function (source) {
   113 		hightlightSource: function (source) {
    80 			source.className += "highlight";
   114 			source.className += "highlight";
    81 		},
   115 		},
    82 
   116 
    83 		save: function () {
   117 		save: function () {